• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to import/refer my css in jsp?

 
Winston Liek
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
accdg to this: http://www.coderanch.com/how-to/java/ResourceUrlProblems

we can use EL expression as follows:

${pageContext.request.contextPath}

but there's no instructions as to how I will set its value.

Sorry I'm noob in jsp

And also, what would happen in case I refer 2 css files in my jsp and both defines the following:
CSS 1 :


CSS 2:

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Liek wrote:but there's no instructions as to how I will set its value.

You don't have to. This expression will automatically evaluate to the context path. (Assuming, of course, that your web app is properly configured and the EL is properly evaluating.)

accdg to this

Please UseRealWords. Thanks.
 
Winston Liek
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can I know what is my context path?

Currently here is my folder structure under WebContent folder:




what I want is to refer the style.css inside the Home.jsp. Can you please tell me how can I do it?
And also, what configurations are you referring to?

Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Liek wrote:how can I know what is my context path?

You don't need to. That's why you use that EL expression, it figures out what the context path is so that you do not have to hardcode it.

Currently here is my folder structure under WebContent folder:

Ugh. You used an IDE to generate this. Sigh.

In any case, it looks like the CSS file is in the css folder, so the path should be: ${pageContext.request.contextPath}/css/style.css

And also, what configurations are you referring to?

Is the EL working? If so, all is well. If not, that means there's likely an error on the web.xml configuration,

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!