Passing parameters from JSP to Servlets

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Barry Parker

    #1

    Passing parameters from JSP to Servlets

    Is there a way to pass parameters (variables?) from a JSP page to a servlet
    when it is called? This way I can use a generic servlet to do several
    different tasks. The call to the servlet is made by using the JSP forward
    tag.

    Cheers in advance, Barry


  • None

    #2
    Re: Passing parameters from JSP to Servlets

    Sure... You either submit a form, in which case you get at the
    elements of the form with:

    request.getPara meter("someElem entNameHere");

    ....in your servlet (you'll need to cast what that returns to a String
    by the way). You said it was a forward though, so no form
    submission... In that case, simply append your variables to the URL.
    In other words:

    <jsp:forward page="yourServl et?variable=val ue" />

    You use the same method to get at the value in the servlet.

    Frank W. Zammetti
    Chief Software Architect
    Omnytex Technologies


    On Sun, 13 Mar 2005 12:12:29 -0000, "Barry Parker"
    <b.w.parker@war wick.ac.uk> wrote:
    [color=blue]
    >Is there a way to pass parameters (variables?) from a JSP page to a servlet
    >when it is called? This way I can use a generic servlet to do several
    >different tasks. The call to the servlet is made by using the JSP forward
    >tag.
    >
    >Cheers in advance, Barry
    >[/color]

    Comment

    Working...