Solved

passing HTML value to JSP

Posted on 2004-10-04
21
765 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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
Java Exception example issues 11 84
designing in object programming 12 132
throw exception 21 81
jsp login check 12 67
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
How many times a day do you open, acknowledge, or close an IT incident? What’s your process? Do you have a process depending on the incident, systems involved, and other factors? New Relic Alerts gives you options for how you interact with notifica…
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

710 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