• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 2
Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"
#################
 
Ranch Hand
Posts: 196
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic