• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error with my web.xml configuration?

 
Sridhar Venkataraman
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have the following in my web.xml configuration file:




In my root, I have a index.jsp and an images folder that contains graphics.

In the index.jsp file, I have the following line:



NOTE: I have deliberately inserted some text above so that it does not convert to HTML

When I render the page through Tomcat (I use v 5.5), I get this error:

<b> An error occurred at line: 13 in the jsp file: /index.jsp
imageURL cannot be resolved
10:
11: <body>
12: <div id="header">
13: <img src="<%=imageURL%>Header.png" alt="GSDC 5P - Role Based Training" />
14: </div>
15:
16: <div id="main" </b>

I have included the @page directive on top of the index.jsp file, and the image name and location are also correct.

What am I missing here? Thanks in advance for looking into this.
[ May 20, 2008: Message edited by: Sridhar Venkataraman ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're missing a lot of important concepts. Firstly, init params in a servlet are only available to the declared servlet. Perhaps its context params that you are thinking of?

And if that's the case, context params will not be available via scriptlets. What led you to believe that they would be. And... if you are using Tomcat 6, why would you be using scriptlets in place of the EL and JSTL?

Check out the implicit variables of the EL to find out how to access context params.
 
Sridhar Venkataraman
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was thinking about context-param as well like you pointed out as a possible reason.

I did not know context-params would be unavailable through scriptlets. Basically, I saw another implementation of a web application where the web.xml file had this declaration (among many others). And a JSP page was accessing this parameter through a scriptlet. But there is a controller servlet in between, which is the reason why this won't work.

Thank you. I can connect the dots now .
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sridhar Venkataraman:
I did not know context-params would be unavailable through scriptlets.




They're not unavailable.
It's just that they're not automatically converted into page level variables.

To access the ServletContext object from within a scriptlet, you would use the implicit variable "application".


[ May 21, 2008: Message edited by: Ben Souther ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic