| Author |
Problem with url paths
|
chaitanya karthikk
Ranch Hand
Joined: Sep 15, 2009
Posts: 779
|
|
Hi all, I am writing a sample login application. All my pages are under WEB-INF/jsp/ folder, only welcome page is in the root directory which in turn will forward the request to a page in WEB-INF/jsp/ directory using a controller.
My problem is with the relative paths. My project structure is:
In my webapp/welcome.jsp page the code is
This will forward the request to a WelcomeController in which I am resolving the view like this
This is my web.xml
This is how my beginner-servlet.xml looks likeMy AuthenticationConroller looks like this
The problem is when I forward the request to WEB-INF/jsp/welcome.jsp page the links is the page are getting a relative path like this
/springbeginner/authentication/registerpage
Now when I click on the register link it goes to AuthenticationController's showRegistrationForm method. It looks like this
Now in the register.jsp page I have some form with action mapped to a controller like thisNow the "back" link gets a relative path springbeginner/authentication/registerpage/welcome. When I click this it says 404 error. So I used This is hitting the WelcomeController. Is it good to put this ../../ in the code? or what approach should I take?
I hope all understood my problem. I think I explained a lot for a small problem, but I dint find any better way to explain. My apologizes.
Good day, thank you all in advance.
|
Love all, trust a few, do wrong to none.
|
 |
Bill Gorder
Bartender
Joined: Mar 07, 2010
Posts: 1282
|
|
Is it good to put this ../../ in the code? or what approach should I take?
sure or alternatively use JSTL to create URL's which will prefix the context root.
for example if welcome is right off your context root, it might look something like below:
On a side note if I understand what I think your doing you are reinventing the wheel. You should take a look at spring-security for this sort of thing.
|
[How To Ask Questions][Read before you PM me]
|
 |
chaitanya karthikk
Ranch Hand
Joined: Sep 15, 2009
Posts: 779
|
|
|
Thank you Mr. Bill. I will check
|
 |
 |
|
|
subject: Problem with url paths
|
|
|