하얀배터리 2019. 11. 17. 02:22
728x90

 

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Insert title here</title>

</head>

<body>

<h2>로그인 화면</h2>

<form name ="myform" method="get" action="LoginOK.jsp">

 

    <p>

        아이디 : <input type ="text" name="m_id">

    </p>

    <p>

        비밀번호 : <input type= "passwd" name="pwd">

    </p>

    <p>

        <input type="button" value="전송"/>

        <input type="button" value="취소"/>

    </p>

</form>

 

</body>

</html>

 

 

 

출력 

 

 

 

jsp 만들기 

 

 

 

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

 

한글 깨지는 것 방지하는 코드 

 

 

기본 Jsp

 

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>title</title>

</head>

<body>

 

</body>

</html>

 

 

 

<h2>전송된 아이디는  ?  <%= %> %>>: </h2>

<h2>전송된 페스워드는 ? :</h2>

 

 리퀘스터와 레스판스가 동시에 일어나야 함  그것을 합쳐논 것 

 

<%= request.getParameter("pwd") %>

 

 

방식 

갭 방식 -> 주소에 값을 실어 보내는 방식  도메인주소쪽에 pw id 가 다 보임 

 

포스트 -> 주소가 깔끔함 . 

 

 

 

 

 

 

 

 

400번 에러 -> 문서 에러 

 

500번 에러 -> 프로그램 에러 

 

 

 

 

 

Ctrl +F3 알아서 재부팅 

 

이클립스 

 


 

 

 

 

  1. 우측 클릭이나 File -New -Dynamic Web project 를 이용해서 프로젝트를 하나 만들어 준다.                                  [ 메뉴바에서 File -New -Dynamic Web project 를 이용 ]

 

 

       

       

 

 

 

 

 [기본 구성 화면]

         

  

 

 

 

 

 

 

 

 

  1. WEB -INF  우측클릭 NEW - JSP File  

 

       

 

 

[결과] 

 

        

      

WEB- INF 아래                                                                  web.xml 파일이 필요하다. 방법 2가지가 있다. 1. jsp파일 추가시 같이 추가.

test. Jsp 파일이 생성된것을 확인 할 수 있다.                                                                                          2. 나중에 추가 

 

 

 

web.xml 파일이 나중에 추가하기 

              

  

 

 

web.xml 파일 

<?xml version="1.0" encoding="UTF-8"?>

 

  <display-name>jsp</display-name>

  <welcome-file-list>

    <welcome-file>index.html</welcome-file>         index.html 파일부터 default.jsp 파일까지 모두 미리 약속된 파일 

    <welcome-file>index.htm</welcome-file>

    <welcome-file>index.jsp</welcome-file>          [서버에서 경로를 꼭 파일이름 외 여기에 있는 이름으로 사용하여도 상관없음 ]

    <welcome-file>default.html</welcome-file>

    <welcome-file>default.htm</welcome-file>

    <welcome-file>default.jsp</welcome-file>

  </welcome-file-list>

</web-app>

 

 

 

 

 

  1. WebContent jsp 경로에 폴더를 만들어 준다.  

                                         

 

                New  - Folder          

 

                

 

 

  1.  New Folder 가 뜨면 finish 클릭

 

                  

 

 

  1. New -> Html file

 

             

 

 

 

 

 

  1. jsp  만들기 

 

             

 

 

 

  1. New - JSP File 

 

            

 

 

 

 

 

 

 

  1. new -> packge 

 

 

 

           

 

 

  1. New -> Serviet

 

           

 

 

 

 

 

          패키지는 자바에서 폴더의 개념 

          패키지 안에 

          Java Resource -> src 우클릭  -> 패키지 생성 -> 패키지 에서 우클릭->  뉴 -> 서블릿 (serviet) 

 

 

           연결은 .jsp

           java 파일 모두 만들어서 가능 

 

           그러나 자바 보안 우수  [서블릿] 

 

        

 

 

 

 

 

 

 

 

728x90