Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

is it good to use a path inside jsp starting with WEB-INF?

 
Ranch Hand
Posts: 114
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I said urgent because I have this issue and needs to be fixed immediately.

I have a jsp which is in some folder outside WEB-INF. This is my project structure and I can not change it.
Now this jsp contains something like :

<%@ include file= "../something.inc"

This file .inc resides inside WEB-INF/somefolder/.

I get 'included file not found' exception.

So is it a good idea to give the path like :
<%@ include file= "/WEB-INF/somefolder/something.inc"

OR

I should just copy something.inc file to the location where my jsp is orginally trying to find ?


This will be deployed on a production environment. So I hope it does not create any problem.



 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using the path starting with "/WEB-INF" is vastly preferred over using page-relative paths starting with "..".

Do not just start copying files around. That'd just likely lead to a big old mess!
 
Tiya Khambadkone
Ranch Hand
Posts: 114
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the quick response and I will make sure next time I don't use uregent,etc. words.

Why is WEB-INF usage preferred ?

Isn't using relative path better than absolute ?
 
Bear Bibeault
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tiya Khambadkone wrote:Isn't using relative path better than absolute ?


The path starting with "/WEB-INF'" is relative. An absolute path starts with the protocol (e.g. http: or https:)

But there are a number of types of relative paths, each of which may be required or preferred in different situations:

  • server-relative path, starts with the context path. Preferred for URLs initiated from the browser (e.g. images, script files, stylesheets, form actions, and so on).
  • context-relative path, starts with "/" and is relative to the context base. The path starting with "/WEB-INF" is a good example. Preferred for paths used on the server for resources within the same web app (includes, forwards, etc).
  • page-relative path, relative to the current URL path. Anything that starts with "." or ".." or a file or folder name relative to the current path. These are fragile because they are relative to something that may change (current path) and should not be used in Java web applications. (The one exception is paths within stylesheets which cannot be easily prefixed programmatically with the context path.)


  • The path starting with ".." is a page-relative path and should not be used.
     
    Bear Bibeault
    Sheriff
    Posts: 67637
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    This comes up enough that I've gone ahead and created a new entry in the JSP FAQ to cover it.
     
    Tiya Khambadkone
    Ranch Hand
    Posts: 114
    1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for the reply. Highly appreciated .
     
    What does a metric clock look like? I bet it is nothing like this tiny ad:
    Free, earth friendly heat - from the CodeRanch trailboss
    https://www.kickstarter.com/projects/paulwheaton/free-heat
    reply
      Bookmark Topic Watch Topic
    • New Topic