Spring
-
Social Media 만들기 - 19) socket io 사용하기 ( App.js 문제 해결!)Spring 2021. 8. 2. 22:48
이번엔 socket io를 사용해서 알림을 가도록 설정해보자. 먼저 server에 socket 사용을 위한 세팅을한다. 서버쪽에 npm i socket.io, 클라이언트 쪽에 npm i socket.io-client해준다. const SocketServer = require('./SocketServer') //Socket const http = require('http').createServer(app) const io = require('socket.io')(http) io.on('connection', socket=>{ console.log(socket.id + ' Connected') SocketServer(socket) }) const port = process.env.port || 5000 ht..
-
Database App with JDBC : 학생 정보를 업데이트하고 삭제하는 기능 만들기 (Update, Delete)Spring 2021. 6. 19. 17:45
update먼저 해보자. 먼저 업데이트 링크를 만들어준다. 여기서는 먼저 로드해서 데이터를 업데이트폼화면에 보여주도록 LOAD 커멘드라우트를 만들어 줄 것이다. FooBar University First Name Last Name Email Action ${tempStudent.firstName} ${tempStudent.lastName} ${tempStudent.email} Update 여기서 Update의 링크를 복사해서 보면, 다음과 같이 보인다. http://localhost:8080/web-student-tracker/StudentControllerServlet?command=LOAD&studentId=5 command와 studentId가 확인 되는 것을 볼 수 있다. 이제 command와 학..
-
Database App with JDBC : 학생을 추가하는 기능 만들기 (Create)Spring 2021. 6. 19. 16:31
이번엔 학생을 학생리스트에 추가해서 저장하는 기능을 만든다. 먼저 Add new 버튼을 만들어주자. add-student-form.jsp을 만들어주자. FooBar University Add Student First name : Last name : Email : Back to List 이제 컨트롤러에 add가 작동하도록 설정하자. route에 따라서 작동을 다르게 하도록 switch구문을 사용했고, addStudent함수를 구현해줬다. studentDbUtil에 addStudent라는 함수를 만들고 구현할 것이다. package com.yunhalee.web.jdbc; import java.io.IOException; import java.util.List; import javax.annotation...
-
Database App with JDBC : 학생 리스트 DB에서 가져오기 (Read)Spring 2021. 6. 18. 22:33
먼저 mysql workbench에서 sql script(다운받은 파일중에) 차례대로 2개를 실행시켜준다. 이후에 다운받은 폴터의 lib안에서의 mysql-connector-java-8.0.19jar파일을 우리가 만든 web-student-tracker 다이나믹 프로젝트안의 lib 폴더로 복사해준다. 추가로 META-INF 폴더안의 context.xml파일도 같은 위치로 복사해준다. 이제 com.yunhalee.web.jdbc 패키지를 만들고 그안에 TestServlet을 만드는데, 다음과 같이 조건을 변경해서 생성해준다. package com.yunhalee.web.jdbc; import java.io.IOException; import javax.annotation.Resource; import ja..
-
MVC : MVC의 기본작용방법Spring 2021. 6. 18. 22:29
먼저 tagdemo에서 사용했던 jstl을 사용하기 위해서 lib안의 내용을 복사해서 servletdemo에 붙여주자. 그다음 controller servlet을 만들자. doget 을 다음과 같이 오버라이딩 해준다. protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //Step 0: Add data String[] students = {"Susan", "Anil", "Trupti"}; request.setAttribute("student_list", students); //Step 1: get request dispatcher RequestDi..
-
Servlets : 기본 사용 방법Spring 2021. 6. 18. 21:52
먼저 dynamic web project를 실행한다. servletdemo프로젝트를 만들고 servlet을 새로 만들어준다. (com.yunhalee.servletdemo 패키지 안에 HelloWorldServlet생성) 생성된 servlet파일에서 doget 함수만 오버라이딩 해준다. protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //Step 1: set the content type response.setContentType("text/html"); //Step 2: get the printwriter PrintWriter out = re..
-
JSP : Standard JSP Tag Library (JSTL) - I18N Tags (Multi-Lingual App)Spring 2021. 6. 18. 20:28
international Language=> (i와 n사이에 18개의 문자로 이루어져서) I18N으로 불린다. 먼저 리소스 파일을 만들자 먼저 디폴트 리소스 파일을 만든다. 새로운 패키지를 만들고 파일을 만들어준다. label.greeting = Howdy label.firstname=First Name label.lastname =Last Name label.welcom = Welcome to the training class. 이제 추가로 독일어 버전, 스페인어 버전을 넣어준다. mylabels_de_DE.properties label.greeting = Hallo label.firstname=Vorname label.lastname =Nachname label.welcom = Willkomen in..
-
JSP : Standard JSP Tag Library (JSTL) - Functional TagsSpring 2021. 6. 18. 19:02
function태그는 다음의 코드를 가지고 있어야 한다. function-test.jsp Length of the string ${data} : ${fn:length(data)} uppercase, startswith를 추가하자. Length of the string ${data} : ${fn:length(data)} Uppercase version of the string ${data } : ${fn:toUpperCase(data) } Does the string ${data } start with luv? : ${fn:startsWith(data, "luv") } 이제 split, join을 해보자. Split Demo ${tempCity} Join Demo Result of joining: ${fu..