Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When to use "/" in front of a Path ?

 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when to use path "/net/major/javaclass" , "net/major/javaclass"??

When to use "/" in front of a Path ?


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64829
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Always. Otherwise the path is page-relative and that's a recipe for failure.
 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
path is page-relative


what is meant by "path is page-relative"??,Could you please explain this??
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jacob deiter wrote:
what is meant by "path is page-relative"??


related to the current url .
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64829
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seetharaman venkatasamy wrote: related to the current url .

Exactly. Which is fine for web sites consisting of static HTML pages. But can be a big problem for web apps where URLs are mapped to servlets whose URLs do not reflect folders in the file system.
 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry .I am really confused.Please explain with more details??
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jacob,

Sorry .I am really confused.Please explain with more details??


say your servlet url pattern is as below

<url-pattern>/login/ProcessLogin</url-pattern>

and say forward to a jsp , if you dont use "/" , it assumes to refer inside /login and search for jsp inside login directory. Use of "/" make sure that you are referencing from Context path.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic