aspose file tools*
The moose likes JSP and the fly likes How to pass a javascript variable value from a JSP page to a Servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to pass a javascript variable value from a JSP page to a Servlet?" Watch "How to pass a javascript variable value from a JSP page to a Servlet?" New topic
Author

How to pass a javascript variable value from a JSP page to a Servlet?

dukeRavi yadav
Greenhorn

Joined: Jul 07, 2011
Posts: 2

Scenario:I have a JSP page named "menu.jsp". On this page the user have to choose a choice from a menu and i have implemented onclick("myredirect(choiceValue)") on each menu item using javascript...
this function uses confirm pop-up box to check whether the user want to continue with his current choice.. if user select ok then it'll return true and it will be stored in check variable...
now i want to send this choiceValue to a servlet named "CheckLogin.java" which checks whether the user is logged in using session tracking ..if the user isn't logged in he'll be redirected to "login.jsp" page
otherwise he'll be redirected to "instructions.jsp" page
..i have implemented the whole stuff as below...and i want to use the "choiceValue" throught the session but its not working as i expected....Please somebody help me !!!


"menu.jsp"
#########



"CheckLogin.java"
#################
Piyush Mangal
Ranch Hand

Joined: Jan 22, 2007
Posts: 196
How are you calling your menu.jsp?



Instead of checking the session as null or new , you should set an user object as an atttribute in session when you first login to your application and then check its value in servlet filter (filter should exclude your login url, otherwise you will end up in a loop) so that you can keep track of user session.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to pass a javascript variable value from a JSP page to a Servlet?