Solved

passing HTML value to JSP

Posted on 2004-10-04
21
762 Views
Last Modified: 2010-04-01
Frds,
   I want to pass selected value from HTML(may be Text or drop down)
to JSP code ?
Thanks in advance ...
karan
0
Comment
Question by:Manish
  • 8
  • 6
  • 5
21 Comments
 
LVL 33

Accepted Solution

by:
hongjun earned 25 total points
ID: 12216591
You can always do this

<form action="page2.jsp" method="post">
<input type="text" name="Text1">
<input type="submit">
</form>


in your page2.jsp, you do this to get the text value
    request.getParameter("submit");


hongjun

0
 
LVL 33

Expert Comment

by:hongjun
ID: 12216609
to print out the text, you do this

out.println(request.getParameter("Text1));


hongjun
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 12216610
You will have to resubmit the page and retreve the parameter.

for example:

<%
  if (request.getParameter("myTextField") != null) {
%>   alert('Parameter found: <%=request.getParameter("myTextField")%>');
<%}
%>

<form method="post" name="myform" action="#">
  <input type="text" name="myTextField" onBlur="this.form.submit();">
</form>

/Nick
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 33

Expert Comment

by:hongjun
ID: 12216616
ignore my first comment on "request.getParameter("submit");"...
0
 
LVL 11

Author Comment

by:Manish
ID: 12216623
I want to use on same page without submitting ?
Is it possible?
0
 
LVL 33

Expert Comment

by:hongjun
ID: 12216639
For the same page, you can always use METHOD=get and submit to the same page.
To retrieve it, you do the same thing.
0
 
LVL 33

Expert Comment

by:hongjun
ID: 12216640
<form method="get">
...
</form>
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 12216645
>>I want to use on same page without submitting ?
>>Is it possible?

I'm afraid not.
0
 
LVL 11

Author Comment

by:Manish
ID: 12216670
But I have to remember all other selected value..
Is it possible to pass the value to javascript and use in
java code of jsp?
0
 
LVL 9

Assisted Solution

by:Nick_72
Nick_72 earned 25 total points
ID: 12216689
no it's not, since javascript is executed on the client, while all jsp code is processed on the server. That is why you have to submit the page so the server gets the values.
0
 
LVL 11

Author Comment

by:Manish
ID: 12216699
So without sumit it is not possible?
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 12216706
that's right
0
 
LVL 11

Author Comment

by:Manish
ID: 12216878
Thanks hongjun and Nick..
U both cleared my problem...
There should be sharing points among u...
karan
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 12217102
There is a feature to share points ;) not now though, it's too late since it's already accepted.
No problem.

/Nick
0
 
LVL 33

Expert Comment

by:hongjun
ID: 12217349
0
 
LVL 33

Expert Comment

by:hongjun
ID: 12224258
@ee_ai_construct

OK. I am fine with the split if the questionner replies.

hongjun
0
 
LVL 11

Author Comment

by:Manish
ID: 12247988
How to share points ,Sorry I dont know?
0
 
LVL 33

Expert Comment

by:hongjun
ID: 12255754
Yeah.
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 12257278
Thank you guys, I appreciate it :)

/Nick
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
password protect pdf 11 77
equalIsNot  challenge 43 160
struts spring hibernate example 12 131
java operators 3 120
The business world is becoming increasingly integrated with tech. It’s not just for a select few anymore — but what about if you have a small business? It may be easier than you think to integrate technology into your small business, and it’s likely…
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question