• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Dropdown menu in Servlet to displayed the selected value  RSS feed

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a Servlet with a dropdown menu of Items to be selected.
Upon selecting and clicking a submit button, the doPost will be invoked, and another section with some graphics will appear below the dropdown menu. However dropdown menu will no longer show the selected value since the doPost rewrite the dropdown menu.

doPost(){

if click() {
write the dropdown menu and a section with Graphics.
}
}

How can i have the selected value still displayed?

Upon selecting another item (before the submit button is clicked), I want to remove the section again. So that after another item is selected and submit button is clicked, then I shall display a section below with other graphics.

Any help is greatly appreciated.

[ September 11, 2006: Message edited by: Bear Bibeault ]
[ September 11, 2006: Message edited by: Ken Flor ]
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ken,

According to you requirement description it is better to apply an AJAX solution.

It needs a little servlet + javascripting.
-Lanka
 
Ken Flor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

thanks for your reply. However we are building from Servlet.

I find it a hassle that Servlet either call doGet or doPost and will override and re-paint the current html screen.
Is there anyway that we can prevent it from override/re-paint the screen? So that my selected value from drop down menu will not be overridden?


thanks.
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ken Flor:

I find it a hassle that Servlet either call doGet or doPost and will override and re-paint the current html screen.
Is there anyway that we can prevent it from override/re-paint the screen? So that my selected value from drop down menu will not be overridden?



Yes, and Lanka just told you what it is.

That you're coding the server side of this app with Servlets (or PHP, or ASP, or Perl, etc..) doesn't change the fact that the end result is going to be client side HTML and Javascript. If you don't want to re-draw the entire screen, you're going to have to do some client side scripting.
[ September 12, 2006: Message edited by: Ben Souther ]
 
Ken Flor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

thanks for all the help rendered.

Can I just check. If I use AJAX, can I embed the AJAX codes in my servlet?

So that dropdown menu is binded to the AJAX. So if i choose something in the dropdown menu, AJAX sent to the the same servlet, and did some processing and return the value without reloading the servlet.
Yet at the same time, if there is another button called "Show Content" on the same servlet, and if I click on this button, it will invoke doGet?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!