File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Receiving a value from servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Receiving a value from servlet" Watch "Receiving a value from servlet" New topic
Author

Receiving a value from servlet

tatiana erm
Greenhorn

Joined: Jul 11, 2012
Posts: 5
Hello!
I'm trying to receive the "result" attribute (wich is equal to expression) to my jsp, but i always get "nul" there

actually it should be like that :
1. insert some expression
2. click Calculate
3. see the "expression" in the "result" field

could anyone spot my mistake?

thank you very much!

regards, tania.

servlet:





JSP:

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

just clarification: <input type="text" readonly="readonly" value= <%= request.getAttribute("result") %> /> why is this?

[EDIT] Ok, understand to display result .
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

one doubt: how do you submitting the form?
tatiana erm
Greenhorn

Joined: Jul 11, 2012
Posts: 5
I click "Calculate" button :)
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

tatiana erm wrote:I click "Calculate" button :)

interesting dude :) . is tere any work around in javascript or how is it submitting form to servlet?
tatiana erm
Greenhorn

Joined: Jul 11, 2012
Posts: 5
i get parameter

String action = request.getParameter("action");

and if it is calculate, i do the job
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Ok, actually <button/> tag is new to me... :wink:
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Ah,
Tips and Notes
Note: If you use the <button> element in an HTML form, different browsers may submit different values. Use <input> to create buttons in an HTML form.

Source:Here

Thanks dude. now I know <button> :thumbup:
tatiana erm
Greenhorn

Joined: Jul 11, 2012
Posts: 5
I'm afraid THIS does not help me anyhow
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Sounds like you are using more than one form.
</form>

<form action=""> ?

what is the action url?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

Is this about submitting the form, or getting the value of the scoped variable "result"? If the latter, the form is irrelevant.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Receiving a value from servlet