File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Paths to use for links Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Paths to use for links" Watch "Paths to use for links" New topic

Paths to use for links

Wilson Gordon
Ranch Hand

Joined: Apr 07, 2007
Posts: 89
In the JSP include files for my project, I use absolute path (starts with /) for the links since those files are included in JSPs that are located in different levels. However, a link such as "/about" ended up as "http://localhost:8080/about". To solve the problem, currently I included the name of the webapps in the path, such as "/myapp/about", but those links would become broken when deployed to a production server.

Is there a better solution?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60817

Never hard-code the context path. Use:


(assumes JSP 2.0)

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Wilson Gordon
Ranch Hand

Joined: Apr 07, 2007
Posts: 89
Thanks Bear!
jQuery in Action, 2nd edition
subject: Paths to use for links
Similar Threads
NoClassDefFoundError JavaMail..........
JSP Include doesn't work
A trouble of System class path
Problem in executing java project jar file
Eclipse Packaging files