This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JSP and the fly likes Remain in same page even after submitting the form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Remain in same page even after submitting the form " Watch "Remain in same page even after submitting the form " New topic

Remain in same page even after submitting the form

Rakesh Keerthi
Ranch Hand

Joined: Jul 16, 2012
Posts: 152

I'm using a jsp to post data to a servlet, but after posting the data i want to stay back insame jsp.
1) I have a jsp here with 2 textboxes. i use a javascript to copy data from one to another on a button click.
2) I use the same button to post data to a database.
3) I want both the actions to be done at a time and should not go to the third jsp(servlet post result), but , should go to another jsp i use.

i'm able to handle these 2 things seperately but together i'm unable to do it. the data gets updated in database and shows a new line in the first text(that's my fault i'm using the redirect way) or moves the data from first textbox to another and doesn't do the data posting. please help me about doing it. below is the code piece i used to do it.

java script to copy data and post data are:

the methods for the button are declared as follows:

<table><tr><center><td><input type="Submit" value="Allocate" id="Send" onClick="invoke(0);move();" style="width:150px" style="font-size:100%"/></td></center></tr></table>

and the servlet code i used are as follows.

i want to post the data aswell as be on the same with the textbox value copied into second textbox, as i would be using it for my further referrence.

I agree. Here's the link:
subject: Remain in same page even after submitting the form
jQuery in Action, 3rd edition