Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to transfer variables between pages?

I'm totally new to JSP, though i know a little bit of JAVA coding.
Can anyone guide me in this. Let's say i declare a variable in first JSP. can i use this variable in another JSP file?If so how to do it?
Thank you very much.
Regards

Comments

  • tprashanttprashant Member Posts: 5
    : I'm totally new to JSP, though i know a little bit of JAVA coding.
    : Can anyone guide me in this. Let's say i declare a variable in first JSP. can i use this variable in another JSP file?If so how to do it?
    : Thank you very much.
    : Regards
    :


    JSP provides many way to pass variable between pages.

    1) Store in the session. sessio is the implicit object in jsp. you can use sesion

    session.setAttribute("var1","value1");

    value1 = session.getAttribue("var1")

    as soon as you finish use of session you should write
    session.invalidate() for better performance



    2) you can use application object same way(not recomanded because value will be visible to all user)

    3) store in Cookies

    4) you can pass as hidden variable in form or append in url as querystring


Sign In or Register to comment.