Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get a variable and print in same page

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

I need to get a variable from a combobox and print in same page.Is it possible.If yes,please guide me to do this.
The following is the code to select ratio from combobox


Thanks
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are probably generating a form through this servlet code, action attribute value of this form should map to the same servlet.
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This servlet name is campaignselection.java.I am submitting the values to another servlet as follows.

Now I have to submit the form to same servlet?
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so far as my knowledge goes it can be achieved in 3 ways
1. Submit to the same servlet
2. If submitted to another servlet, the second servlet forwards the request back to the servlet which generates the form
3. If submitted to another servlet, the second servlet displays the output and includes the first servlet, so from user point of view it will appear on the same page.
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for you reply.But my actual problem is ,if i submit the form two frames will be opened ,In one frame the main page displays with a combo box to choose a network and stop button.another frame will show which network I have selected and submitted.If i select a network from the combo box and click stop button ,I am unable to close the second frame.Thats why i tried to use stop as link instead of a button and call a javascript function which forwards the whole frames to the page we required.But using stop as link(ie)


By using this i can able to close the two frames and open the new page.But i am unable to get the variables which is selected in the combo box.

Thats why i thought if i am able to print the variable selected in the combox in the samepage ,i will put that in session and get that in session when clicking stop.

If it is a wrong method,please give me a suggestion to do this.

Thanks again.
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe you can always pass the selected combo box value as a querystring

i.e.



now in servlet (i.e. url pattern AsiaLogout) you can always receive this value


 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

a href='http://localhost:8080/Voicebroadcast/AsiaLogout?commboxvalue=thevalueselected'

The value selected is dynamic.Then what should i mention there?
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//the following code snippet might provide you some help, just a html page, as per your requirement you need to embed inside servlet, but for presentation logic its always better to use jsp


 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
sorry for the delayed reply.thanks for your reply.It works fine. As per your suggestion i have changed the servlet to jsp.Thanks a lot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic