Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

passing HTML value to JSP

Posted on 2004-10-04
21
Medium Priority
?
773 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
19 Comments
 
LVL 33

Accepted Solution

by:
hongjun earned 100 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Aerodynamic noise is the cause of the majority of the noise produced by helicopters. The inordinate amount of noise helicopters produce is a major problem in the both a military and civilian setting. To remedy this problem the use of an aerogel coat…
Ranking ecommerce websites is a vital process. You need to have a strong SEO (Search Engine Optimization) strategy. If you don’t have one, you are losing out on brand impressions, clicks and sales. Check this guide on how to improve website traffic …
Integration Management Part 2
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

773 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