본문 바로가기

개발하자/JSP&Servlet

텍스트필드 입력값 다음페이지로 넘기기

 

localeTest.war

 

 

a.jsp

===========================

<%@ 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>
 <script src="http://code.jquery.com/jquery-1.7.js"> </script>
<script type="text/javascript">
$(document).ready(function(){
 $("#aTag1").click(function(){
   var buffer=[];
   buffer.push("lo=ko");
   buffer.push("id="+$("#txt1").val());
   buffer.push("pw="+$("#txt2").val());
   location.href="fmt1.jsp?"+buffer.join("&");
   });
 $("#aTag2").click(function(){
   var buffer=[];
   buffer.push("lo=en");
   buffer.push("id="+$("#txt1").val());
   buffer.push("pw="+$("#txt2").val());
   location.href="fmt1.jsp?"+buffer.join("&");
   });

});
</script>
<body>
id : <input type="text" id="txt1">
pw : <input type="text" id="txt2"></br>

<a href="#" id="aTag1">한국어</a> |
<a href="#" id="aTag2">영어</a>
</body>
</html>

 

fmt1.jsp

==================

<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:setLocale value="${param.lo}" />
<fmt:bundle basename="a.b.member" >
<!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>
 <fmt:message key="MSG">
 <fmt:param value="${param.id}"/>
  <fmt:param value="${param.pw}"/>
 </fmt:message>

</body>
</html>
</fmt:bundle>

 

 

 

=====================================================

모듈화

a.jsp

====================

<%@ 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>
 <script src="http://code.jquery.com/jquery-1.7.js"> </script>
<script type="text/javascript">
$(document).ready(function(){
 $("#aTag1").click(f);
 $("#aTag2").click(f);
 
 function f(){
  var str=$(this).html();
  var lo="en";
  if(str=="한국어"){
   lo="ko";
  }
   var buffer=[];
   buffer.push("lo="+lo);
   buffer.push("id="+$("#txt1").val());
   buffer.push("pw="+$("#txt2").val());
   location.href="fmt1.jsp?"+buffer.join("&");
 }
});
</script>
<body>
id : <input type="text" id="txt1">
pw : <input type="text" id="txt2"></br>

<a href="#" id="aTag1">한국어</a> |
<a href="#" id="aTag2">영어</a>
</body>
</html>