• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with url paths

 
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Mr. Bill. I will check
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic