• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

forward values in jsp(see code)

 
rich werth
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to pass the vars to another page to do something with them. I don't know how to forward the values to another page. Help!
<head>
<title>
direction
</title>
</head>
<%
String button = request.getParameter("button");
String table = request.getParameter("table");
String c_name = request.getParameter("c_name");
String [] kys = request.getParameterValues("pkey");
if (button == null) {
out.print("<html><head></head><body>Please go back and tell me what you want me to do!</body></html>");
}
else if (button.equals("Delete Checked Items")) {

}
%>
<body>
<%=button%><br><%=table%><br><%=c_name%><br>
<% for (int i=0; i<kys.length; i++)
System.out.println("The info is.....: " + kys[i]);
%>
</body>
</html>
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Get a reference to the requestDispatcher and then use that to forward the request. Just remember that you will not be able to send any output to the client.
ex. RequestDispatcher rs = getServletContext().getRequestDispatcher("path/servlet name")
rs.forward(yourrequestreference, yourresponsereference)


------------------
Bosun
SCJP for the Java� 2 Platform
 
rich werth
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
I'm using this in stead. Will it cause any problems?
String button = request.getParameter("button");
String table = request.getParameter("table");
String c_name = request.getParameter("c_name");
String [] kys = request.getParameterValues("pkey");
if (button == null) {
out.print("<html><head></head><body>Please go back and tell me what you want me to do!</body></html>");
}
else if (button.equals("Delete Checked Items")) { %>
<jsp:forward page="del.jsp" />
<jsp aram name="table" value=table />
<jsp aram name="c_cname" value=c_name />
<jsp aram name="kys" value=kys />
<%}%>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic