File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Error with my web.xml configuration? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Error with my web.xml configuration?" Watch "Error with my web.xml configuration?" New topic

Error with my web.xml configuration?

Sridhar Venkataraman
Ranch Hand

Joined: May 22, 2006
Posts: 76
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
11: <body>
12: <div id="header">
13: <img src="<%=imageURL%>Header.png" alt="GSDC 5P - Role Based Training" />
14: </div>
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

Joined: Jan 10, 2002
Posts: 63858

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.

[Asking smart questions] [About Bear] [Books by Bear]
Sridhar Venkataraman
Ranch Hand

Joined: May 22, 2006
Posts: 76
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

Joined: Dec 11, 2004
Posts: 13410

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 ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: Error with my web.xml configuration?
It's not a secret anymore!