querystring problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arshan
    New Member
    • Mar 2008
    • 1

    querystring problem

    Hi

    I am not sure if this post is better suited to Javascript forum or Java. So please let me know if I should send it to Java forum.


    Hi

    I have a JSP in which three links exist:


    Code:
    <a href="javascript:myFunc('<%= request.getContextPath()%>/myservlet?myVar=0')" > Option 0 </a>
     <a href="javascript:myFunc('<%= request.getContextPath()%>/myservlet?myVar=1')" > Option 1</a>
     <a href="javascript:myFunc('<%= request.getContextPath()%>/myservlet?myVar=2')" > Option 2 </a>


    Each link forwards the request to the same servlet with different values for the variable myVar. Inside servlet, there are if-else statements for handling each variable value.

    The problem is, if the page is refreshed, the value of the last request is still in myVar and it causes actions to happen when they should not. How can I prevent that ?

    If the page is displayed for the first time and refreshed this problem does not occur, since myVar is empty. But if the page is used once and it should be used again, and it is refreshed, the value of the request variable remains.

    Could you please help?

    Thanks
    Arshan
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Don't use the URL for setting the variable.

    What does setting myVar do?

    Comment

    Working...