How to use jsp:forward with onclick event ?


Web tier: servlets, JSP, Web frameworks: How to use jsp:forward with onclick event ?

  1. How to use jsp:forward with onclick event ? (5 messages)

    How do I use jsp:forward after a user clicks a link? In other words, I want to pass the request object, received in my jsp file to another jsp file, only after the user has clicked (onclick event) in my jsp page. If I use jsp:forward in the onclick event the second jsp is automatically forwarded without displaying the first jsp file.
  2. a href="#" onclick="'URI?QueryString','NewWindow',
  3. Thanks for help.

    I wanted to use jsp:forward because I want to pass request object of the displayed jsp page (a.jsp), to the forwarded jsp page (b.jsp).
    If I simply put onclick with href=b.jsp page on a.jsp, the b.jsp page gets displayed,yes, but it does not get the request object(parameters recvd with POST method) of a.jsp page.
    I don't want to use querystring with b.jsp page as it is a long list of parameters that are being passed including a password field which gets displayed in the query string.

    Is there any other way to pass request objects hopping from one jsp to another and so on until we stop.
  4. You can use hidden fields inside a form in a.jsp to pass the parameters read from a.jsp to b.jsp and a javascript statement in Href to make this form submited when click on the link. Action attribute of the form in a.jsp refer to 'b.jsp'.
  5. Try:

    storing your request object in the session object. of course you can just use the session object to directly store whatever values you are preserving, but that would involve a lot of casting and conversion.

    so in jsp 1 you can say

    session.setAttribute("request", request);

    and in jsp 2 you can say

    // if you don't care about jsp2's implicit request object
    request = (HttpServletRequest)session.getAttribute("request");


    // if you want to preserve jsp2's implicit request object
    HttpServletRequest request2 = (HttpServletRequest)session.getAttribute("request");

    Now you can treat the new request object as it was in jsp1. Hope this works/helps!
  6. Hi,

      This is guda.. I too also getting the same problem.
    actualy i want to send values from first jsp page to second jsp page. HOW? I am using weblogic server.. is there any need to change in the weblogic properties file.. pls give me ur idea.. with a small example..(code).
    Thank you