wood burning stoves 2.0*
The moose likes JSP and the fly likes to pass input text to other jsp thro servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "to pass input text to other jsp thro servlet" Watch "to pass input text to other jsp thro servlet" New topic
Author

to pass input text to other jsp thro servlet

mohan gavande
Ranch Hand

Joined: Oct 07, 2004
Posts: 39
Hi,
I want to pass the value to other jsp thro servlet like as

<td><input name="assetsName" type="text" id="assetsname"></td>

I want to pass assetName text field to other Jsp thro' servlet without using form & submit how should i pass it?


If it requres the JAVA Script then please give details of that
Thanking in advance
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

How do you expect the value to get sent to the server without a submit?

Perhaps you should back up and describe what you are really trying to accomplish.
[ August 17, 2005: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
mohan gavande
Ranch Hand

Joined: Oct 07, 2004
Posts: 39
Actually,
I have one JSP page which links to other Jsp page. but senario is while passing to other jsp it should carry the text value from current jsp to other jsp
like example,

<input name="assetName" type="text" id="assetname">

& i want to pass assetName's value to other jsp by using <a href. >
without submit
So how should i pass that?

I cannt use submit for that because i will use that for final submition
if you still doesn,t understand the scenario, then feel free for details explanation.
waiting for replay...
& Thanking in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41634
    
  55
I cannt use submit


I doubt that that is really true, if you adapted your server-side accordingly.

You can load a different JSP page through JavaScript by assigning a value to window.location.href. The value you assign can contain paramters like so:
window.location.href = "second.jsp?parameter=value"
where you get the value from the contents of your form.


Ping & DNS - my free Android networking tools app
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by mohan gavande:

& i want to pass assetName's value to other jsp by using <a href. >
without submit
So how should i pass that?

You could use a query string variable:

These can be retrieved with request.getProperty just like form variables.


I cannt use submit for that because i will use that for final submition
if you still doesn,t understand the scenario, then feel free for details explanation.
waiting for replay...
& Thanking in advance.

I don't understand what you mean by "Final Submit".
If you're moving from page to page, you're going to lose the field values unless you are sending them up to the server and storing them there.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ola Daniel
Ranch Hand

Joined: Jul 27, 2005
Posts: 105
Ben is right... if you are moving from page to page. Before you get to a final
submit page where you commit your data. You might want to store your data in a temporary DB table or somewhere on your server and save your self the truoble of passing parameters from page to page.


SCJP 1.4, SCWCD 1.4
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler et al, Refactoring: Improving the Design of Existing Code, 1999
mohan gavande
Ranch Hand

Joined: Oct 07, 2004
Posts: 39
Hi again,
Actually in my project there is one main page which takes some input text.
from
in that i have
<input name="assetName" type="text" id="assetname">
like these inputs then i want to pass one parameter which is comming from asstName & i want to pass that value using <a href > to other jsp. after going to other jsp, it uses to that jsp & after submitting, other jsp, the flowes again comes to privious jsp page. & in that when i press submit buttn, all values goes to database.
So how should i make code for that???
the main thing is how should i pass that value to other jsp &
other thing if i come to main jsp, is there text values which i enters before are present or not
pippiri venu
Greenhorn

Joined: Apr 19, 2005
Posts: 8
for these you can pass the variable through this
i.e href="nextPage.jsp?Name=<%=Value%>"



venu gopal p
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You do realize that HTTP is a stateless protocol, right?
Each time you make a request to the server (either via hyperlinks or HTTP Form submission) you are loosing everything from the previous request unless you take specific steps on the server side to maintain it.

One such step would be to store the data in session.
Another would be to write it to a scratch table or record in your database.
Rajesh Agarwal
Ranch Hand

Joined: Aug 01, 2005
Posts: 79
Anyways I think the first form in the first JSP needs to be submitted. The in the second form in the second JSP. we can retrieve the values of the submit.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: to pass input text to other jsp thro servlet