File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Change of URL upon validation in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Change of URL upon validation in jsp" Watch "Change of URL upon validation in jsp" New topic
Author

Change of URL upon validation in jsp

aditya damaraju
Greenhorn

Joined: Feb 18, 2008
Posts: 1
I am using struts web framework in my application. I am also doing a lot of validations for the values entered through the UI, using the Struts validation framework. But upon a validation error the request is forwarded to the same jsp page with the validation error showing up using the struts <html:error/> tag. But my problem is upon a validation error the url dispayed on the address bar is changing even while the jsp remains the same. This might be happening because, upon a validation error actionservlet might be doing a forward request dispatch to the input jsp page. But the requirement specifies that the URL should not change even upon a validation error. Is there anyway that the URL remains the same upon validation error. For example: in the Landing.jsp page where the URL is "localhost:8080//Landing.jsp", if there are any validation errors in this page upon submitting the form in this page to "MyProject/LandingAction.do" the URL should not change to the "localhost:8080//MyProject/Landing.jsp" while still showing the Landing.jsp page

It wud be of great help to me if any one cud giv a solution to this issue

THANKS IN ADVANCE!!!
[ February 18, 2008: Message edited by: aditya damaraju ]
Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
Hi aditya ,

I do not understand why you want to stay on the same url i.e your jsp.
Whenever something like populating requests happens on the server side the url will be changed. Same is the case with your struts errs.
Struts errs are generated by the server side.
so the URL will be change.
Another thing;
you are saying that the url on your page is like .jsp.
This is not wrong but it is not according to the conventions.
The URL should not be visible i.e. with jsp extension.
This is a bad practice.
Try to display your url like .do

Regards.


Khushwinder
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
Originally posted by Khushwinder Chahal:
Hi aditya ,

I do not understand why you want to stay on the same url i.e your jsp.
Whenever something like populating requests happens on the server side the url will be changed. Same is the case with your struts errs.
Struts errs are generated by the server side.
so the URL will be change.
Another thing;
you are saying that the url on your page is like .jsp.
This is not wrong but it is not according to the conventions.
The URL should not be visible i.e. with jsp extension.
This is a bad practice.
Try to display your url like .do

Regards.


What you are saying is if i am on url: www.abc.do and submit with some validations issues; struts can not be configured to go back to the same url after validation fails?


Kishore
SCJP, blog
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
That is a very odd (and too low level in my opinion) requirement.

"This might be happening because, upon a validation error actionservlet might be doing a forward request dispatch to the input jsp page."

The reason is that the user clicked the submit button and the browser sent a request to your action to process the page (LandingAction.do). To get the old URL back you would have to redirect to the jsp page but that would cause you to loose all the data that was submitted on the request.

It seems like if you really want to do this then you need to perform validation before the page is submitted. You could use client side JavaScript for this or you could use an Ajax call so that the validation is done on the server side.

- Brent
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Change of URL upon validation in jsp