aspose file tools*
The moose likes JSP and the fly likes Simple question Redirect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Simple question Redirect" Watch "Simple question Redirect" New topic
Author

Simple question Redirect

Adam Teg
Ranch Hand

Joined: Feb 09, 2006
Posts: 36
I am redirecting to a new page and passing the variables in the redirect. How can I capture it in the survey.jsp page?

response.sendRedirect("survey.jsp"+"?firstName="+firstName+"&lastName="+lastName+"&emailAddress="+emailAddress);

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

"AdamSmith Smith",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Adam Teg
Ranch Hand

Joined: Feb 09, 2006
Posts: 36
I couldn't find my original user name and password.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

Thanks for adjusting your display name.

Regardless of how your target page is arrived at -- a redirect, typing directly into the browser, a link on a page -- you would obtain the values of the request parameters with one of the getParameter family of methods on the request object.
Adam Teg
Ranch Hand

Joined: Feb 09, 2006
Posts: 36
Thanks

I have a response.sendRedirect that I append some values. Can I do a POST instead of the default GET.

response.sendRedirect("survey.jsp"+"?firstName="+firstName+"&lastName="+lastName+"&emailAddress="+emailAddress+"&didHeLie="+0);

Secondly, I still cannot get the variables on the survey.jsp using the response.getParameter(firstName);
What am I doing wrong?

Any help would be appreciated.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

A redirect will always result in a GET.

Employ basic debugging techniques. First, is the URL in the address bar after the redirect well-formed?
Chris Brat
Ranch Hand

Joined: May 22, 2003
Posts: 108
In the page that you redirect to try getting the parameters from the request, not the response.

Chris


SCJP 1.2, SCJP 5, SCBCD
Adam Teg
Ranch Hand

Joined: Feb 09, 2006
Posts: 36
Thanks again,

Can someone tell me what this error means?

org.apache.jasper.JasperException: business.User.(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String V

This is continued by a lot of:

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
Adam Teg
Ranch Hand

Joined: Feb 09, 2006
Posts: 36
Never mind my greenhorn friends. After starting tomcat things looked much better.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple question Redirect