File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Query String or any other solution please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Query String or any other solution please" Watch "Query String or any other solution please" New topic

Query String or any other solution please

Rakesh Keerthi
Ranch Hand

Joined: Jul 16, 2012
Posts: 149
Hi I have a jsp in which there is a textbox, what i wanted to do is after posting the data i want a redirection happening in and string in ADD(please refer the below code) to be in the empty text box in page 1, the problem i'm facing is there is a query in first page which is making this textbox empty. i heard that i can take use of QueryString() or please suggest me any other process if available, but i'm not sure of how to use it. the redirection code is as below.

and the name of my text box is tgt1 in page 1.

R. Jain
Ranch Hand

Joined: Aug 11, 2012
Posts: 375

What does your first page look like?? Can you post the code of your JSP page containing the textbox you are displaying value in?

*PS: - Ideally, it is a very bad practice to code so much of Business logic (That too containing database talk) in your JSP..
Your JSP should just do the task of displaying the data, rest of the business logic should go into a controller (A Servlet)
Rakesh Keerthi
Ranch Hand

Joined: Jul 16, 2012
Posts: 149
the above is code of a servlet. and the jsp i used is as follows.

Howard Watson
Ranch Hand

Joined: Jan 07, 2004
Posts: 56
String s="Users.jsp?tgt1="+Add+"";(i wanted to know what should go here)

I'm not sure what you are looking for here, but would create a URN with a query string parameter named tgt1 with the value of Add appended.
In the context of your coding style your JSP would have and your input would be
Comments: You have two inputs outside your form in your JSP. One has
indicating you do have your database code in your JSP. And based on this
<input type="Submit" style="display: none" value="Add Query"id="Query_but" onclick="invoke(2);">
you probably have your javascript code in it as well. When you get this working it would be a good idea to follow R. Jain's PS and practice some separation of concerns (SoC). You're knee deep in bear scat here.
I agree. Here's the link:
subject: Query String or any other solution please
jQuery in Action, 3rd edition