get방식

url값으로 정보가 전송되어 보안에 약함


post 방식

url 변경 없이 header를 이용해 정보가 전송되어 보안에 강함







참조 : https://blog.naver.com/013318/221154535343



cmd창에서 포트번호 확인

netstat -a -n -o -p tcp


중첩되는 포트번호 강제종료

taskkill /f /pid 포트번호





아니면


톰캣 수동으로 stop한 후에 실행해도 해결되었다

'programing > JSP' 카테고리의 다른 글

JSP - JSP 특징, get방식, post방식, web.xml에 서블릿 맵핑  (0) 2018.03.21
JSP - 구구단 출력하기  (0) 2018.03.08
아파치 실행 법  (0) 2018.03.08
JSP - 입력한 두 수의 합 출력  (0) 2018.02.23
JSP - 웹 양식 만들기  (0) 2018.02.23

<%@ page language="java" contentType="text/html; charset=EUC-KR"

    pageEncoding="EUC-KR"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

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

<title>Insert title here</title>

</head>

<body>

 

<%-- 

<%!   %> 선언문(자바 변수, 메소드 선언)

<%    %> 스크릿렛(자바 로직)

<%=   %> 표현(html 출력)

<%-- --> 주석

--%>

 

<%! 

      StringBuilder sb = new StringBuilder();

%>

 

<% 

      for(int i=1; i<=9; i++) {

            sb.append(String.format("3 × %2d %2d", i, 3*i));

            sb.append("<br />");

      }

%>

 

<%=

      sb.toString()

%>

 

 

</body>

</html>


참조 사이트 : http://withcoding.com/25


아파치 폴더 - bin - startup.bat 클릭

이클립스에서 작성함


클래스명 : myForm1.jsp


<?xml version="1.0" encoding="EUC-KR" ?>

<%@ page language="java" contentType="text/html; charset=EUC-KR"

    pageEncoding="EUC-KR"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

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

<title>Insert title here</title>

</head>

<body>

 <form action="myForm2.jsp" method="post">

    <!--action은 서버 쪽 주소(jsp로 구성), 여기에서는 html에 보냄-->

    <table>

        <tr>

            <td>숫자를 입력하세요</td>

            <td>

                <input type="number" name="num1" id="num1">

                <!-- 서버에서는 name으로, 자바스크립트는 id로 인식하므로 둘의 이름을 같게 명시해야 한다-->

            </td>

        </tr>

        <tr>

            <td>숫자를 입력하세요</td>

            <td><input type="number" name="num2" id="num2"></td>

        </tr>

        <tr>

            <td colspan="2"></td><!--컬럼 2칸 합치기-->

            <td><input type="submit" value="전송"></td>

        </tr>

    </table>

    </form>

</body>

</html>








클래스명: myForm2.jsp


<?xml version="1.0" encoding="EUC-KR" ?>

<%@ page language="java" contentType="text/html; charset=EUC-KR"

    pageEncoding="EUC-KR"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

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

<title>Insert title here</title>

</head>

<body>

  <%

  String num1 = request.getParameter("num1");

String num2 = request.getParameter("num2");


int num3 = Integer.parseInt(num1);

int num4 = Integer.parseInt(num2);

out.println("첫번째 값 : " + num3); 

%>

<br/>

<%out.println("두번째 값 : " + num4);%>

<br/>

<%out.println("합 : " + (num3+num4));%>

</body>

</html>



첫번째 값 : 123
두번째 값 : 456

합 : 579


<form name="입력 폼 이름" action="웹 프로그램 페이지" method="전달 방식">

<input type="폼 모양과 기능" name="입력 폼 변수" value="전달 값">

</form>





이렇게 html에서 하려고 했는데 오류나서


 <form action="myForm2.jsp" method="post">

    <!--action은 서버 쪽 주소(jsp로 구성), 여기에서는 html에 보냄-->

    <table>

        <tr>

            <td>ID</td>

            <td>

                <input type="text" name="id" id="id">

                <!-- 서버에서는 name으로, 자바스크립트는 id로 인식하므로 둘의 이름을 같게 명시해야 한다-->

            </td>

        </tr>

        <tr>

            <td>암호</td>

            <td><input type="password" name="pw" id="pw"></td>

        </tr>

        <tr>

            <td colspan="2"></td><!--컬럼 2칸 합치기-->

            <td><input type="submit" value="전송"></td>

        </tr>

    </table>

    </form>






이클립스에서 이렇게 jsp로 다시 함


클래스명 : myForm1.jsp

여기에서 id와 pw입력 하면


<?xml version="1.0" encoding="EUC-KR" ?>

<%@ page language="java" contentType="text/html; charset=EUC-KR"

    pageEncoding="EUC-KR"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

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

<title>Insert title here</title>

</head>

<body>

<%

String id = request.getParameter("id");

String pw = request.getParameter("pw");

if(id != null){

out.println("ID : " + id);

}

if(pw != null){

out.println("암호 : " + pw);

}

%>

</body>

</html>





클래스명 : myForm2.jsp

여기에 출력 됨


<!-- if(id != null){

out.println("ID : " + id);

}

if(pw != null){

out.println("암호 : " + pw);

} -->


<?xml version="1.0" encoding="EUC-KR" ?>

<%@ page language="java" contentType="text/html; charset=EUC-KR"

    pageEncoding="EUC-KR"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

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

<title>Insert title here</title>

</head>

<body>

<%

String id = request.getParameter("id");

String pw = request.getParameter("pw");

%>

<table>

<tr>

<td>ID</td>

<td>

<%= id %>

</td>

</tr>

<tr>

<td>PW</td>

<td>

<%= pw %>

</td>

</tr>

</table>

</body>

</html>

톰캣 설치


https://tomcat.apache.org/download-90.cgi

위 사이트에 들어가서


32-bit/64-bit Windows Service Installer (pgp, md5, sha1, sha512)

위 인스톨러를 다운받아 설치한다


http://localhost:8080

인터넷주소창에 위와 같이 입력하여 정상 작동하면 톰캣설치 완료된 것

+ Recent posts