I'm trying to access ServletContext attribute that is referenced Foo
object from jsp page, by using jsp scriplet's implicit object
application:
such as
<%
Foo f =(Foo)application.getAttribute("fooObject");
%>
That caused error 500, saying that Foo class can't be accesed from
generated jsp servlet class.
Any suggestions as to why this does not work???
Do I have to specify some special mapping in my application descriptor
(web.xml) ?
Sorry ,I forgot to mention that I'm using tomcat as jsp engine. And this
is application scenario that I setup:
I setup context for my Test web application in server.xml as
<Context path="/Test" docBase="Test"
defaultSessionTimeOut="30" isWARExpanded="true"
isWARValidated="false" isInvokerEnabled="true"
isWorkDirPersistent="false"/>
My application descriptor (web.xml) contain the following:
///////////////////////////////////////////////////////////////////////////////
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>Test</servlet-name>
<servlet-class>TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Test</servlet-name>
<url-pattern>/Test/*</url-pattern>
tern>
</servlet-mapping>
</web-app>
/////////////////////////////////////////////////////////////////
TestSevlet is simple servlet that instantiate Foo object in its init
method and adding it to the ServletContext by using:
Foo f = new Foo();
getServletContext().setAttribute("fooObject", f);
and in its doGet() method forwarding request to one of two jsp pages,
based on some flag.
Second jsp page contain the following fragment in scriplet code :
<%
Foo f =(Foo)application.getAttribute("fooObject");
%>
which caused 500 error, saying that Foo class can't be accesed from
generated jsp servlet class.
Any suggestions as to why this does not work???
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets