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

Posted on 2006-03-28
Last Modified: 2010-04-01
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.
Question by:mytilig
    LVL 35

    Expert Comment

    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

    LVL 19

    Expert Comment

    >>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 :)
    LVL 19

    Accepted Solution

    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 :)



    LVL 23

    Expert Comment

    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.
    LVL 19

    Expert Comment


              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.


    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
    It can often be challenging to stay relevant in the rapidly evolving world of technology. This can make recruiting talent difficult for companies of all sizes.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now