Web Hosting Talk







View Full Version : tomcat, JSP and web.xml file


nachopo
12-15-2002, 10:03 PM
Hi,
I've an error runnign a page and someone told me that the error has occured in the file *.jsp because the entry for the class MiscDataBase is not included in the web.xml file in the servlets folder.
How I can do it ?

regards

i am a
12-15-2002, 10:42 PM
hmm, hard to say "exactly" without having more information, but basically, you have a WEB-INF directory. in that directory is a "web.xml" file. you need to define each servlet in that file for that directory.

ex.

<servlet>
<servlet-name>Hello World</servlet-name>
<description>
Testing Servlets...
</description>
<servlet-class>Hi</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello World</servlet-name>
<url-pattern>/Hi</url-pattern>
</servlet-mapping>


so in this case the servlet is "Hi.class" located in WEB-INF/classes/Hi.class

so in other words, just make sure each class is defined as such, you may have to play around with the paths and whatnot in the web.xml file, but find that's the basic idea (to make sure each class is defined)

nachopo
12-16-2002, 06:23 PM
Originally posted by i am a
hmm, hard to say "exactly" without having more information, but basically, you have a WEB-INF directory. in that directory is a "web.xml" file. you need to define each servlet in that file for that directory.

ex.

<servlet>
<servlet-name>Hello World</servlet-name>
<description>
Testing Servlets...
</description>
<servlet-class>Hi</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello World</servlet-name>
<url-pattern>/Hi</url-pattern>
</servlet-mapping>




Hi

Im geting this error:

/usr/local/jakarta/jakarta-tomcat-4.1.12-src/build/work/Standalone/www.examenesonline.cl/servlet/registro_jsp.java:7: package engine.miscWeb does not exist
import engine.miscWeb.MiscDataBase;
^
/usr/local/jakarta/jakarta-tomcat-4.1.12-src/build/work/Standalone/www.examenesonline.cl/servlet/registro_jsp.java:47: cannot resolve symbol
symbol : class MiscDataBase
location: class org.apache.jsp.registro_jsp
MiscDataBase objMiscDataBase=new MiscDataBase();
^



An error occurred at line: 3 in the jsp file: /registro.jsp

Generated servlet error:
/usr/local/jakarta/jakarta-tomcat-4.1.12-src/build/work/Standalone/www.examenesonline.cl/servlet/registro_jsp.java:47: cannot resolve symbol
symbol : class MiscDataBase
location: class org.apache.jsp.registro_jsp
MiscDataBase objMiscDataBase=new MiscDataBase();
^
3 errors


and I tryed to edit web.xml file but I failed too:

<!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>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
<welcome-file>
index.html
</welcome-file>
<welcome-file>
index.htm
</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>MiscDataBase</servlet-name>
<description>
MiscDataBase.class
</description>
<servlet-class></servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MiscDataBase</servlet-name>
<url-pattern>/MiscDataBase</url-pattern>
</servlet-mapping>
</web-app>


The MiscDataBase.class is localed in / www / servlet / WEB-INF / classes / engine / miscWeb / flder.

regards