*
The moose likes Beginning Java and the fly likes how to get a variable and print in same page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to get a variable and print in same page" Watch "how to get a variable and print in same page" New topic
Author

how to get a variable and print in same page

preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
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

Joined: Jan 08, 2009
Posts: 1473
    
    6

You are probably generating a form through this servlet code, action attribute value of this form should map to the same servlet.


Swastik
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
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

Joined: Jan 08, 2009
Posts: 1473
    
    6

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

Joined: Oct 04, 2007
Posts: 518
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

Joined: Jan 08, 2009
Posts: 1473
    
    6

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

Joined: Oct 04, 2007
Posts: 518

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

The value selected is dynamic.Then what should i mention there?
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1473
    
    6

//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

Joined: Oct 04, 2007
Posts: 518
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get a variable and print in same page