File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes forward values in jsp(see code) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "forward values in jsp(see code)" Watch "forward values in jsp(see code)" New topic
Author

forward values in jsp(see code)

rich werth
Ranch Hand

Joined: Sep 21, 2001
Posts: 57
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

Joined: Nov 06, 2000
Posts: 1506
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


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
rich werth
Ranch Hand

Joined: Sep 21, 2001
Posts: 57
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 />
<%}%>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: forward values in jsp(see code)
 
Similar Threads
problem in jsp !!!
Problem with forwarding page towards error page
Error in request.getParameter
Display of Latin Characters
How to show error messages during validation