No session, no multiple jsp. All i have is one jsp which shows a drop down with go and cancel buttons and based on the drop down the same jsp will be called with respective values(which called from java methods) . Please remember everything is in a single JSP.
something like this,
The Go button carries the dropdown value to the else part
The problem is, the drop down has null at the top followed by options, when nothing selected and clicked on go, an inbuilt java method addError needed to be added and the page shouldn't submitted to next.
Since things should happen after clicking on Go, the page is getting forwarded to the else part. All i want is, is to call the addError method and stay back to the same page even after clicking on "Go".
When you call sendRedirect, that asks the browser to send a new request to whatever URL you provide as the parameter. You don't send a response in this case, all that happens is that your server sends a 302 return code telling the browser to redirect.
If you want the user to see error messages, then they should be in the page you're redirecting to.
Joined: Mar 01, 2010
I understand, but not sure how to stay in the same page after hitting the action submit. Any ideas would be appreciated.
My requirement is, if the null is selected and clicked on "Go", i need the error message to be displayed and the Edit should stay at 6 ie http://localhost:8090/MyProj/MyPage/Edit=6. (which means back to the drop down page)
I am not getting what exaclty you want but as your last post. i think..
and also show an error message.
hope it will help you.
Correct Me if i am wrong
Joined: Mar 01, 2010
Thanks Neeraj and sorry if im not clearing the air.
My project is... every jsp page loads on a command called editCmd. editCmd is the command which will reach a class. So when I click on a link to create a new inventory, the inventory page comes fields(date created, created by, doc id.. etc). One of its field is a drop down called Order Type.
Now the requirement is, when the user clicks on the create inventory link, the drop down page should appear and then to the corresponding type, the other fields to be populated. I have created the page with the dropdown and the others. The requirement is done. The situation is, i need to include a error message if nothing selected and the go pressed.
1. When the user click create inventory, the jsp to populate the drop down -> editCmd =6 (ie dropdown page).
2. When the user clicks on Go (the form submit action takes to) -> editCmd = 5 ( ie fields page based on the entry in the drop down).
If i have selected null and clicked on Go, all the fields appears with null.
But my problem is, when the go is clicked, the action takes me to the editCmd value 5. Which means im already in the submitted class. I can control the look of the JSP by the conditions and make the user to see only the drop down. But since im already in the submitted class, i cannot take the drop down value and resubmit again.
I need some information on how to get back to the callee form from the caller from ie after the action submit, if the value is null, i should get back to old form.