wood burning stoves 2.0*
The moose likes Servlets and the fly likes servlet/jsp not running in tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet/jsp not running in tomcat" Watch "servlet/jsp not running in tomcat" New topic
Author

servlet/jsp not running in tomcat

Giri Prasad
Ranch Hand

Joined: Mar 08, 2001
Posts: 56
Hello
I am trying to deploy am application in tomcat
I installed tomcat and my TOMCAT_HOME, JAVA_HOME are set properly.
When I am trying to compile my servlets and java bean I am getting the compilation errors for all the servletAPI classes like, "HttpServlet not found".
Can anyone help
Thanks
lee dalais
Ranch Hand

Joined: Feb 28, 2001
Posts: 67
hi Giri
u need to have the sevlet API's from the java.sun.com as they don't come standard with the jdk1.3. u need to download the java webserver as the Servlets API's come with that. and then include the new API's in your classpath or add it to the already existing classes file that comes with the jdk1.3, i think it is the rt.jar file.
Giri Prasad
Ranch Hand

Joined: Mar 08, 2001
Posts: 56
Hi Lee
But I think the servlet related classes are there in the tomcat/lib directory???
I am using JDK1.2
I included the tomcat/lib to my classpath too.
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Personally, I would add each of the jar files in the lib
folder to the classpath.
regds.
- satya

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Giri Prasad
Ranch Hand

Joined: Mar 08, 2001
Posts: 56
Thanks Madhav
Cahnging theCLASSPATH to point to all the jars is working. But have another problem.......
I placed all classes, JSP and html as per deployment documentation by tomcat. But my bean class which is in the WE_INF.classes is not getting recognized by my JSPs
Any light on this
Thanks again
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
But my bean class which is in the WE_INF.classes is not getting recognized by my JSPs
Not sure what you mean by WE_INF.classes
If you don't mean the foll., then it would help.
The class files are supposed to be in the WEB-INF/classes
dir not the WEB-INF. Also, if you have a package structure, then
the class files should be in the correct package under the
WEB-INF/classes dir.
regds.
- satya

[This message has been edited by Madhav Lakkapragada (edited March 19, 2001).]
Giri Prasad
Ranch Hand

Joined: Mar 08, 2001
Posts: 56
They are in the correct packege under the WE-INF/classes, Madhav.
Still I am getting the error

maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
What is the error you are getting? Did you spell the class name correctly in jsp files? Please post the initial code part of your bean .java file and the .jsp file which uses it.
regds
maha anna
Giri Prasad
Ranch Hand

Joined: Mar 08, 2001
Posts: 56
Hi Maha
Following is the outline of code

package net.sbcis.dn_worksheet;
import java.beans.*;
import javax.servlet.http.*;
import javax.servlet.*;
public class WorksheetBean {
// variables declaration
// public get methods
//public set methods
}
Here is the JSP call for bean
<jsp:useBean id="worksheet_bean" class="net.sbcis.dn_worksheet.WorksheetBean" sc
ope="request"/>
<jsp:setProperty name="worksheet_bean" property="*"/>
This is how the bean methods are called
<td nowrap><input type="radio" name="reg_internic" value="yes" <%=worksheet_bean
.getReg_internic_c("yes")%>>Yes <input type="radio" name="reg_inte
rnic" value="no" <%=worksheet_bean.getReg_internic_c("no")%>>No</td>
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Giri,
Your bean is within a package called net.sbcis.dn_worksheet . So, you have to create 3 physical dirs under .../web-inf/classes directory and place your bean's class there. In other words your WorksheetBean.class file must be placed like following.

Give it a try and let us know!
regds
maha anna
Giri Prasad
Ranch Hand

Joined: Mar 08, 2001
Posts: 56
The bean is in the proper directory Maha.
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
I simulated your package in my machine and able to run the jsp. No errors.
Are you able to run the examples which come with Tomcat itself? When you type http://localhost:8080, Tomcat main page will be displayed with links to 'Servlet' and 'JSP' examples. Are you able to run them properly?
What's your webAppContext Name? Did your bean class name exactly as 'WorksheetBean' (case sensitive!)
Here is my classpath setup line in c:\autoexec.bat

regds
maha anna

[This message has been edited by maha anna (edited March 20, 2001).]
Giri Prasad
Ranch Hand

Joined: Mar 08, 2001
Posts: 56
I redeployed everything again and the code is working fine. Don't know where I was wrong previously
Thanks to all
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Glad to know [somehow ] we got it working. Sometimes its kind of annoying even if we get it working when we can't get convinced ourselves what went wrong. Isn't? It happened to me sometimes.
regds
maha anna
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
If using Windows and you are setting your classpath statically in tomcat.bat, put this line in your tomcat.bat file.
if exist "%TOMCAT_HOME%\lib\servlet.jar" set CP=%CP%;%TOMCAT_HOME%\lib\servlet.jar
You can put a copy of the servlet.jar in the TOMCAT_HOME\lib directory.
Cheers,
Dave McQ.
 
jQuery in Action, 2nd edition
 
subject: servlet/jsp not running in tomcat
 
Similar Threads
jar files needed?
how to use a separate tomcat 4.0.x with jboss
implement security constraints and assign users
Regarding Tomcatserver
ClassNotFoundException in Jsp Precompilation