wood burning stoves 2.0*
The moose likes Servlets and the fly likes Dropdown menu in Servlet to displayed the selected value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Dropdown menu in Servlet to displayed the selected value" Watch "Dropdown menu in Servlet to displayed the selected value" New topic
Author

Dropdown menu in Servlet to displayed the selected value

Ken Flor
Ranch Hand

Joined: Aug 01, 2006
Posts: 34
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 ]
Lanka Prasad
Greenhorn

Joined: Nov 14, 2004
Posts: 21
Dear Ken,

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

It needs a little servlet + javascripting.
-Lanka


SCJP 1.4
Ken Flor
Ranch Hand

Joined: Aug 01, 2006
Posts: 34
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.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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 ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ken Flor
Ranch Hand

Joined: Aug 01, 2006
Posts: 34
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?
 
 
subject: Dropdown menu in Servlet to displayed the selected value