how to automatically pass parameters between jsp

Discussion in 'Java' started by mmalaidini@gmail.com, Nov 14, 2005.

  1. Guest

    I have one.jsp dealing with some parameters.

    I'd like to modify maybe one of them, and pass the request to another
    jsp (ie: two.jsp) upon user clicking on a link.

    Is there any automatism to do that?

    Or in one.jsp should I modify a bean state at session level, using it
    in two.jsp?
    TIA
    MMan
    , Nov 14, 2005
    #1
    1. Advertising

  2. wrote:
    > I have one.jsp dealing with some parameters.
    >
    > I'd like to modify maybe one of them, and pass the request to another
    > jsp (ie: two.jsp) upon user clicking on a link.
    >
    > Is there any automatism to do that?


    I think you can use the following method:

    HttpSerlvetRequest req;
    req.getRequestDispatcher().forward("yourjsp.jsp");

    or

    req.getRequestDispatcher().include("yourjsp.jsp");


    Doesnt that work?
    Tjerk Wolterink, Nov 14, 2005
    #2
    1. Advertising

  3. Guest

    Tjerk Wolterink wrote:
    > wrote:
    > > I have one.jsp dealing with some parameters.
    > >
    > > I'd like to modify maybe one of them, and pass the request to another
    > > jsp (ie: two.jsp) upon user clicking on a link.
    > >
    > > Is there any automatism to do that?

    >
    > I think you can use the following method:
    >
    > HttpSerlvetRequest req;
    > req.getRequestDispatcher().forward("yourjsp.jsp");
    >
    > or
    >
    > req.getRequestDispatcher().include("yourjsp.jsp");
    >
    >
    > Doesnt that work?


    Yes, but isn't it just like jsp:forward? I don't want to transfer
    current request to another jsp; I'd like to serve my request and
    prepare a link (ie: an href) that will receive a request just like the
    one I served, maybe with some modifications.

    Is that more clearly defined?
    Thanks
    , Nov 14, 2005
    #3
  4. isamura Guest

    <> wrote ...
    : I have one.jsp dealing with some parameters.
    :
    : I'd like to modify maybe one of them, and pass the request to another
    : jsp (ie: two.jsp) upon user clicking on a link.
    :
    : Is there any automatism to do that?
    :
    : Or in one.jsp should I modify a bean state at session level, using it
    : in two.jsp?
    :
    Perhaps you could write a method to rewrite the URL, say rewriteUrl(...) and use it like this:

    HREF="<%= rewriteUrl("two.jsp", "aVar", "newValue") %>"

    ..K
    isamura, Nov 14, 2005
    #4
  5. Guest

    Yes, but it does mean indeed that there is no automatism.

    Thx anyway
    , Nov 15, 2005
    #5
  6. isamura Guest

    <> wrote ...
    : Yes, but it does mean indeed that there is no automatism.
    :
    : Thx anyway
    :
    I am sure you realize any "automatism" must be handled by some sort of "magic" program/routine. In
    your case you can either write the magic yourself or pay someone (like me ;-) to do it for you.

    Cheers!

    ..K
    isamura, Nov 15, 2005
    #6
  7. PrinceJigar Guest

    You can either pass it to two.jsp using parameters.

    <a href="two.jsp?param1=something&param2=something">Click here to go to
    two.jsp </a>

    But if you have a lot of parameter values that u need to pass then you
    can do two things. Either create an object to hold all of the values,
    dump them on the user session ( load on the web container) and then
    retreive that object in two.jsp and take out the various parameters.

    or

    Create a fake form and submit them upon clicking the link. Then use
    request.getParameter("param1) and so on in two.jsp and get the values.
    PrinceJigar, Nov 15, 2005
    #7
  8. Guest

    Thx, in fact I ended up using a session-scoped bean to exchange those
    information between pages.
    MM
    , Nov 16, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kai Grossjohann
    Replies:
    2
    Views:
    800
    Anton Spaans
    Dec 8, 2003
  2. Bharath
    Replies:
    3
    Views:
    2,153
    Robert
    May 10, 2005
  3. Replies:
    0
    Views:
    4,353
  4. sridhar kumar ch
    Replies:
    1
    Views:
    8,583
  5. sridhar kumar ch
    Replies:
    0
    Views:
    799
    sridhar kumar ch
    Jun 28, 2006
Loading...

Share This Page