• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with drop-down box

 
Amarender Reddy
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

in my JSP i have a drop-down box with three options. If selected each

option has its own method to be run. I should be calling these methods only

in the concerned servlet.

now in my servlet how will i know which option of the drop-down is selected.

presented below is the code i have implemented for the same which seems to

be right but is not working.

IN JSP:


the implementation of JavaScript method ListBoxChanged() is as under:


After this in my HTTPSession i'm setting the variable selListItem and i'm

retieving the same in my servlet.

But the value is always zero.

Can anyone kindly rectify the error and help me ASAP...its very urgent.

Thanks and Regards
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amarender,
The session is set when the page is rendered, which is before the form is updated by the user. Instead, use request.getParameter() to get the value from HTML/JavaScript.
 
Amarender Reddy
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne,

with the request stuff also i had the same problem.

the variables 'selListItem' and 'selListItemIndex' of the JavaScript are

global to the entire document. But still i'm not able to access them

outside the script(in JSP). how can i do that?

thank you for your prompt reply

my yahoo id is amarender_kr and i'm online

advices and help is most appreciated

thanks in advance

cheers
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amarender,
It's the same idea with request and session. Both are server side variables. Instead, you need to submit your values with the form. Then the server can recoginize them.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!