Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error with my web.xml configuration?

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 67750
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 .
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Hot dog! An advertiser loves us THIS much:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic