MyEclipse: HowTo: include a servlet in a Web Project that executes

shafir - Jul 31, 2007 - 04:44 PM
Post subject: HowTo: include a servlet in a Web Project that executes
i haven't coded J2EE since 2000, things have certainly changed. i have a project that is mostly JSP's, yet i need to have a servlet so that its Init() method can be used to instanciate several static variables that will be used throughout the JSPs.

my simplest example is a Web Project where i've added a servlet (into /src). i see the entry in my web.xml....

<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<description>yyyyyyyy</description>
<display-name>xxxxxxx</display-name>
<servlet-name>myServlet</servlet-name>
<servlet-class>testweb.myServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>myServlet</servlet-name>
<url-pattern>/servlet/myServlet</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>


when i either run or debug the app, i get the default JSP (index.jsp) displayed, but my breakpoints in "myServlet" are never reached. i'm sure this is configurable, but i cannot find an example.

can anyone point me to the right way to do this??? thanks in advance.....
shafir - Jul 31, 2007 - 05:32 PM
Post subject: RE: HowTo: include a servlet in a Web Project that executes
aha! i have found out that a FILTER on *.jsp is what i need.
All times are GMT - 6 Hours
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits