Solved

passing HTML value to JSP

Posted on 2004-10-04
21
758 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

In  today’s increasingly digital world, managed service providers (MSPs) fight for their customers’ attention, looking for ways to make them stay and purchase more services. One way to encourage that behavior is to develop a dependable brand of prod…
Use of TCL script on Cisco devices:  - create file and merge it with running configuration to apply configuration changes
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now