| |
JSP和会话 |
|
/*
<%@ page import="com.java2s.*"%>
<html>
<head>
</head>
<body>
<h1>Thankyou for your request</h1>
Thankyou for your request for more information.
It will be sent to you shortly.
<%
MoreInfoRequest infoRequest = new MoreInfoRequest();
infoRequest.setCourses(request.getParameter("courses"));
infoRequest.setFirstName(request.getParameter("firstName"));
infoRequest.setLastName(request.getParameter("lastName"));
infoRequest.setEmail(request.getParameter("email"));
// this is the method that will bind an object to a session
session.setAttribute("infoRequest", infoRequest);
%>
<p>Click <a href="displayYourRequest.jsp">here</a> to view your request.
</body>
</html>
*/
package com.java2s;
public class MoreInfoRequest
{
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getCourses() {
return courses;
}
public void setCourses(String courses) {
this.courses = courses;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
private String firstName;
private String lastName;
private String email;
private String courses;
}
<body>
<h1>Your Request</h1>
Here is the information that you submitted to us for processing.
<%
MoreInfoRequest infoRequest =
(MoreInfoRequest) session.getAttribute("infoRequest");
%>
<br>Course name:<b> <%=infoRequest.getCourses()%></b>
<br>Your name: <b><%=infoRequest.getFirstName()%>
<%=infoRequest.getLastName()%></b>
<br>Your email: <b><%=infoRequest.getEmail()%></b>
</body>
</html>
|
|
|
Related examples in the same category |
|