-
form 과 나머지 input 태그 더 살펴보기JAVA/웹 프로그래밍 - 서블릿 2020. 10. 30. 22:47
html파일을 만들어서 실행을 해보자.
그리고 이에 대한 처리를 하기 위해서는 NewForm,java 서블릿이 있어야 함을 알고 있다.
NewForm.html
더보기<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <form method="post" action="NewForm"> <input type="color" name="color"><br> <input type="datetime-local" name="datetime-local"><br> <input type="email" name="email"><br> <input type="file" name="file"><br> <input type="image" name="image"><br> <input type="month" name="month"><br> <input type="number" name="number"><br> <input type="radio" name="radio"><br> <input type="range" name="range"><br> <input type="reset" name="reset"><br> <input type="search" name="search"><br> <input type="tel" name="tel"><br> <input type="time" name="time"><br> <input type="url" name="url"><br> <input type="submit" value="전송"><br> </form> </body> </html>
NewForm.java
더보기package com.iot.web; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet("/NewForm") public class NewForm extends HttpServlet { private static final long serialVersionUID = 1L; protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setCharacterEncoding("UTF-8"); response.setContentType("text/html;charset=UTF-8"); request.setCharacterEncoding("UTF-8"); PrintWriter out = response.getWriter(); String color = request.getParameter("color"); String datetime_local = request.getParameter("datetime-local"); String email = request.getParameter("email"); String file = request.getParameter("file"); String month = request.getParameter("month"); String number = request.getParameter("number"); String radio = request.getParameter("radio"); String range = request.getParameter("range"); String reset = request.getParameter("reset"); String search = request.getParameter("search"); String tel = request.getParameter("tel"); String time = request.getParameter("time"); String url = request.getParameter("url"); out.println("color : " +color +"<br>"); out.println("datetime-local : " +datetime_local +"<br>"); out.println("email : " +email +"<br>"); out.println("file : " +file +"<br>"); out.println("month : " +month +"<br>"); out.println("number : " +number +"<br>"); out.println("radio : " +radio +"<br>"); out.println("range : " +range +"<br>"); out.println("reset : " +reset +"<br>"); out.println("search : " +search +"<br>"); out.println("tel : " +tel +"<br>"); out.println("time : " +time +"<br>"); out.println("url : " +url +"<br>"); } }
소스 파일
'JAVA > 웹 프로그래밍 - 서블릿' 카테고리의 다른 글
웹 브라우저에서 수의 덧셈을하고 출력하기 (0) 2020.11.01 Filter (0) 2020.10.30 form을 활용한 아이디와 비번 입력 받기(select,date,다중선택,checkbox) (0) 2020.10.30 form과 textArea & 한글 깨짐 해결 (0) 2020.10.30 form 형태로 전달하기 (0) 2020.10.30