Passing parameters from a Jsp page that does not have a <form> or page body

From my main JSP that has a form and form elements, I call action.jsp that does some validations and pass the data to java classes.
action.jsp does not have any <form> or  body. But has the return data from my java classes.

I would like to forward the user to thanks.jsp and also display the return data from action.jsp.

How can I pass these parameters to thanks.jsp?
1. I tried to pass as hidden, but since there is no <form>, it does not work.
2. response.redirect did not seem to pass the parameters
3. One suggestion on EE was
RequestDispatcher reqDisp = request.getRequestDispatcher("/thanks.jsp");
reqDisp.include(request, response);
<%@ page errorPage="Exception.jsp" %>

But it does not work either....

When I execute it, the control always goes to exception.jsp and there is no log entires.  Can you tell me what could be the error?
Also, how can I see the actual error mesage when I use <%@ page errorPage tag?
Thank you.
Who is Participating?
Another might be easier way is to use :

<jsp:forward page="thanks.jsp">
   <jsp:param name="param1" value="<%=value1%>" />

The good thing in java world is that you always can come up with a lot of solutions. Unless I find 3 ways to do it, I never stop :)



Store them in the session...

    session.setAttribute( "object1", o1 ) ;
    session.setAttribute( "object2", o2 ) ;



    session.getAttribute( "object1" ) ;

on the other side...

I would do validation AND processing in action.jsp and then put the results into the session for the next page to pick up after the redirect

>>RequestDispatcher reqDisp = request.getRequestDispatcher("/thanks.jsp");
reqDisp.include(request, response);

     This should be a better way because your action.jsp looks like a controller (a servlet like). But here are a few things you need to make sure:

      (1) is "/thanks.jsp" your a correct path? The path is relative to your context root. If your thanks.jsp is inside a subdirectory under your web root, you need to provide it as "/subfolder/thanks.jsp". OR, if thanks.jsp is in the same folde r as action.jsp, just write it as "thanks.jsp" (this might be your choice).
      (2) you might use reqDisp.foward(request,response) instead of reqDisp.include(...).
      (3) you need to put your value into request object in your action.jsp as:
           and take it out  in thanks.jsp as:
       see this:

     btw: You can look at the log file to see detailed error message.

Enjoy :)
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
Ok try out this one.

When you are in action.jsp after validating every thing put the data on to the session using session.setAttribute("SessVar",your variable name");

the forward using jsp:forward to the Thanks page.

And there you retrieve back the data from the session & display.

Thank You.

          TimeYate already said that ...

         Also, I already mention jsp:forward and you don't need session if you use that.  I already list all possible solutions VERY clearly. You can look at my comments to learn it.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.