This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
In My Application i have a requirement of submitting a bulk data say(a Person's Detail)to database.
Once a perticular record is submitted to dB, I want a message to be displayed that the person is Successfully Added To DB.
And User can Add one more Person Info.
What i deed is after submitting the data if there's no error came i assigned the result as Success.
And Stored in the request object with key say "key".
In the JSP page i am having a hidden parameter whose value is assigned by the following
First of all this doesn't look like a hidden field to me
This is a text field. I suppose you meant this
Also why are you making it complicated by using javascript in this. If you want to show a pop up box to the user then its ok. The second thing is that if you are setting the key in the servlet which stores the data in the database, then you must have set an attribute instead of parameter. So your code would look like
or even better
And this is a problem of double posting I think. Not only will the user be displayed the message, the data will also be persisted more than once. So you'll have to make sure that this is avoided. For that you must use a unique ID sort of a thing which is stored in the session as well as sent to the browser to identify that the same thing has been posted more than once...
where have you called the alert box? I mean in the form's action element or SUBMIT button's onSubmit element?
The greater danger for most of us is not that our aim is too high and we miss it, but that it is too low and we reach it
abinash das
Ranch Hand
Joined: Apr 26, 2008
Posts: 52
posted
0
i am calling at bodyOnload
Sujai Kaarthik
Ranch Hand
Joined: Dec 29, 2008
Posts: 162
posted
0
then it will pop-up everytime you load that page. Try to add alert box when you submit the form.
between, once you submit the form, where the page redirects? to the same page or other page?
abinash das
Ranch Hand
Joined: Apr 26, 2008
Posts: 52
posted
0
In My application what i deed is from a jsp page i am submitting the dat to a Servlet,
From the Servlet i am invoking a DAO to insert into DB.
After i am done i am getting a response back as "Success or Failure".
Then I am using response.redirect to a servlet which constructs the parameters for the .jsp
So, Can you suggest me where to use the alert.?
Sujai Kaarthik
Ranch Hand
Joined: Dec 29, 2008
Posts: 162
posted
0
Then I am using response.redirect to a servlet which constructs the parameters for the .jsp
what is the intended purpose of this action?
after inserting in the DB, where do your page redirects? to the same page or anyother page?
I guess that alert box is your only problem. right?
abinash das
Ranch Hand
Joined: Apr 26, 2008
Posts: 52
posted
0
The intention is to show some Conformation message to User that the given data is Successfully inserted
into Database.And i am redirecting the request to a Servlet which takes certain values from the DB, and then
dispatches the request to the .jsp page.