This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
The servlet is located in, "/home/webapps/servlets/WEB-INF/classes/com/domain/myServlet"
If I execute http://domain.com/index.jsp I get the following error,
"The value for the useBean class attribute com.domain.myServlet is invalid"
If I change the context in the server.xml file to the following it works.
<Context path="" docBase="."></Context>
This is because it executes the index.jsp file in the appBase directory of "/home/webapps/servlets/index.jsp"
It appears the code in the index.jsp file in "/home/user/public_html" can not find the servlets in the appBase.
So how do I tell code in the index.jsp in the public_html directory how to find the servlets in appBase.
That's a funny way to use a servlet. Strictly speaking, servlets are executable objects invoked directly from URL requests and not something that you'd include into a JSP with a "useBean" tag. Also, it's strongly discouraged these days to include Context definitions in the Tomcat server.xml file. They should be separate files in the TOMCAT_HOME/conf/Catalina/localhost directory or in the WAR's META-INF/context.xml file.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Aug 15, 2011
I know Tomcat has its own way to map classes.
I have dozens of applications that were developed as far back as 10 years ago using Resin.
The Resin web.xml file allows a classpath configuration,
<classpath id='/home/webapps/servlets/WEB-INF/classes' source='/home/webapps/sources' />
that lets you set the classpath to anywhere you wanted on a host basis.
I have seen a number of posts where porting from Resin to Tomcat becomes difficult due to this exclusion. After all, a JSP page is a servlet that should be able to use a class where-ever it is located.
I guess this is all based on packaging an entire application in a WAR file instead of having pieces of the application all over the place.
I just wish I did not have to reconfigure the all the Resin apps to conform to Tomcat!
I know about the context statement in the TOMCAT_HOME/conf/Catalina/localhost.
I was just trying to make the example simple.