• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Change of URL upon validation in jsp

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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'm still in control here. LOOK at this tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic