1
JSP 페이지간에 데이터 (값) 전달 시도 중. HTML 코드에 사용자가 입력 한 것과 동일한 이름과 나이를 표시하고 싶습니다.여러 JSP 페이지간에 데이터를 전달할 수 없습니다.
내 프로그램에는 3 개의 파일이 있습니다. 흐름
inputname.html -> printname.jsp -> printclass.jsp
- inputname.html입니다 : 사용자가 자신의 이름과 나이를 입력
- printname.jsp : ALL 세 표시 : 이름과 나이 입력 자신의 자격
- printclass.jsp 표시 이름을, 연령 및 자격.
문제 이름은 나이가 적당하지 않습니다. printclass.jsp
; 값은 null
입니다.
printname.jsp
에서
관련 코드 :
<html>
<head>
<title>Welcome</title>
</head>
<body>
<% String Name=request.getParameter("name");%>
<% String Age=request.getParameter("age");%>
<h1 >
welcome
<%= Name%>,
<%= Age %>
</h1>
<br><br>
<form method="POST" action="http://localhost:8090/htmltojsp1/printclass.jsp">
<% request.setAttribute("name",Name) ; %>
<% request.setAttribute("age",Age) ; %>
<h3>choose a Class</h3><p>
<select name="class" size="1">
<option>School
<option>College
<option>bsc
<option>mca
</select>
<br> <br>
<center>
<input type="SUBMIT">
</center>
</form>
</body>
</html>
관련 코드 printclass.jsp
에서 :
<html>
<body>
<h1 >
<% String Name=request.getParameter("name");%>
<% String Age=request.getParameter("age");%>
<h1 >
welcome
<%= Name%>,
<%= Age %>
</h1>
<br><br>
<br><br>
<h2>you are in
<%= request.getParameter("class")%>
<h2>
</body>
</html>
감사합니다. 이제 정상적으로 작동합니다. – Incognito
Np, 도움이된다면 대답을 수락하는 것을 잊지 마십시오. –
JSp - Servlet Tutorial에 대한 좋은 링크를 보내주십시오. – Incognito