Execute servlet in TomCat
how can i Execute servlet in tomcat4.1?
is there any setting?if yes what is that?
already i installed jsdk
and set the class path
where i want to save servlet file?
how can i Execute servlet in tomcat4.1?yes.
is there any setting?if yes what is that?
already i installed jsdk
and set the class path
where i want to save servlet file?These are very basic questions. You should read some tutorial and be more specific with your questions.
http://www.coreservlets.com/
Even while describing your basic problems, it is a good idea to describe what you have followed so far and which is the confusing step.
Similar Messages
-
Executing Servlets thru Tomcat 5.5.17.
I have just installet Tomcat 5.5.17 in order to execute Servlets.
Though the service is running,I am unable to access it.
When I say:
http://localhost:8080
it prompts me with a username and password screen:
I enter 'admin' as the user name and password is blank:
but am unable to go to the tomcat page.
Has anyone encountered this before?
I even tried entering 'tomcat' as user and 'tomcat' as password.I enter 'admin' as the user name and password is
blank:
but am unable to go to the tomcat page.
Has anyone encountered this before?
I even tried entering 'tomcat' as user and 'tomcat'
as password.How about admin/admin?
Anyway, those credentials should be there, in some xml configuration file (admin.xml ? -- don't remember). -
Problem in executing servlets under tomcat 4.1
Dear Group,
I am using Tomcat 4.1 and have the following directory structure:
1. C:\Tomcat 4.1\webapps\testapp
----It is my root directory and I have my html file called
sample.html
2. C:\Tomcat 4.1\webapps\testapp\WEB-INF------web.xml is here
3. C:\Tomcat 4.1\webapps\testapp\classes\TestServlet.class
-------here I have the servlet, no package---only one servlet
My[b] web.xml has entry for:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/TestServlet</url-pattern>
</servlet-mapping>
</web-app>My[b] sample.html contains:
<HTML>
<BODY>
<form method="post" action="http://localhost:8080/testapp/TestServlet">
<input type=submit value="showServlet">
<h2>
<font color="green">First try on Serlvet</font>
</h2>
</form>
</BODY>
</HTML>Here is what I have done:
1. Started the Tomcat server
2. In the IE browser, I typed http://localhost:8080/testapp/sample.html
-------- - the file shown correctly and I clicked the showServlet button.
3. I got the follow error �HTTP Status 404 - /testapp/TestServlet" the
requested resource not availble
4. when I clicked the showServelt button the control goes to another page
(as it should go to execute the servlet) .
The URL is �http://localhost:8080/testapp/TestServlet�
Please enlighten me where I went wrong?Hello all,
Thank you for answering the question now the servlet gets executed.
I here posts the steps i carried out to execute the
servlet. If anyone have different idea pls post. Im
pasting here the steps also attaching one.
Steps to create your directory and work in Tomcat 4.1
1. Create your directory in Tomcat�s webapps Directory.
-----If your tomcat is in d:\ the your directory may look
----- D:\tomcat\webapps\<your directory>
------E.g. �d:\tomcat\webapps\test�
2. In the test directory you can your html files directly or you can create a
directory to hold html files.
--------E.g. �d:\tomcat\webapps\test\first.html (OR)
-------E.g. �d:\tomcat\webapps\test\html-files\first.html�
3. Create a folder called WEB-INF inside test
-------E.g. �d:\tomcat\webapps\test\WEB-INF
------ Under the WEB-INF folder put your web.xml file
4. Create another folder named classes under the same test
----- E.g. �d:\tomcat\webapps\test\classes
----- Here you need to place your servlet classes
----- E.g. �d:\tomcat\webapps\test\classes\testServlet.class
5. Start any browser that are java enabled
6. Type �http://<machine name (or) IP add.>:8080/<your folder
name>/<html file>�
---- E.g. http://localhost:8080/test/ html-files/first.html
-----E.g.http://127.0.0.1:8080/test/html-files/first.html
7. Click the component (button, label�) to enable servlet
8. That�s all! Now you should get your servlet executed.
Files:
1. web.xml
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems,
Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>testServlet</servlet-name>
<servlet-class>testServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testServlet</servlet-name>
<url-pattern>/testServlet/*</url-pattern>
</servlet-mapping>
</web-app>
2. first.html
<html>
<body>
<form method="POST"
action="http://localhost:8080/test/testServlet">
<input type=submit value=click></input>
</form>
</body>
</html>
3. testServlet.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class testServlet extends HttpServlet
public void doPost(HttpServletRequest req,
HttpServletResponse res)throws ServletException,
IOException
PrintWriter out = res.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<h1>Hello! </h1>");
out.println("</body>"+"</html>");
}I have put my first.html inside the folder
�d:\tomcat\webapps\test\html-files\� and testServlet
is under �d:\tomcat\webapps\test\WEB-INF\classes\� folder. -
How to execute servlets in tomcat?
Hi,
I have compiled servlet file and tried to execute that file from root i.e. (http://localhost/'filename'....)as class file is in web-inf/classes.But it is executing from "http://localhost/servlet/" where is that servlet directory?
why all servlets executes from "servlet/" directory?
Please reply....
Thanx in advance.I has the same problem, and my solution was to include a line in the tomcat-auto file foreach servlet i had.
Under
JkMount /MyApp/servlet/* ajp13
I set a line
JkMount /MyApp/MyServlet ajp13
and in the web.xml of my webapp i included a servlet mapping for the servlet:
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>MyPackage.MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/MyServlet</url-pattern>
</servlet-mapping>
Then restarting tomcat and apache it worked.
One question i have is that tomcat-auto file it is supposed to be auto-generated by tomcat, but in my case it is not, each time i add an app in the webapps dir i have to add all the stuff in tomcat-auto file. Does anyone know how to autogenerate this file? -
How to execute servlet in tomcat
i have one jsp which is in the folder:- webapps/examples/Contact.jsp this is the code of contact.jsp:-
<jsp:include page="Home.jsp" flush="true"/>
<SCRIPT LANGUAGE="JavaScript1.1">
function submission1() {
if(document.contactus.name.value =="" )
alert("please fill the Name");
return;
else if(document.contactus.organization.value =="")
alert("please fill the organization");
return;
else if(document.contactus.designation.value =="")
alert("please fill the designation");
return;
else if(document.contactus.telephone.value =="")
alert("please fill the telephone");
return;
else if(document.contactus.city.value =="")
alert("please fill the city/Country");
return;
else if(document.contactus.message.value =="")
alert("please fill the message");
return;
document.forms[0].action = "MailServlet";
document.forms[0].submit();
</SCRIPT>
<body>
<form method="post" name="contactus">
<TABLE BORDER=0 CELLPADDING=4>
<TR>
<TD ALIGN=RIGHT width="124"><b>Mail Server Host</b></TD>
<TD ALIGN=LEFT width="298">
<% String l_svr = (String)session.getAttribute("smtpServer"); %>
<INPUT TYPE="text" NAME="p_smtpServer" SIZE=60
VALUE="<%= l_svr!=null ? l_svr : "" %>" >
</TD>
</TR>
<TR>
<TD ALIGN=RIGHT width="124"><b>Name</b></TD>
<TD ALIGN=LEFT width="298">
<INPUT TYPE=TEXT SIZE=60 MAXLENGTH=60 NAME="name">
</TD>
</TR>
<TR>
<TD ALIGN=RIGHT width="124"><b> Name of Organization *</b> </TD>
<TD ALIGN=LEFT width="298">
<INPUT TYPE=TEXT SIZE=60 MAXLENGTH=200 NAME="organization">
</TD>
</TR>
<TR>
<TD ALIGN=RIGHT width="124"> <b>Your Designation *</b> </TD>
<TD ALIGN=LEFT width="298">
<INPUT TYPE=TEXT SIZE=60 MAXLENGTH=200 NAME="designation">
</TD>
</TR>
<TR>
<TD ALIGN=RIGHT width="124"><b> Telephone No.</b> </TD>
<TD ALIGN=LEFT width="298">
<INPUT TYPE=TEXT SIZE=60 MAXLENGTH=100 NAME="telephone">
</TD>
</TR>
<TR>
<TD ALIGN=RIGHT width="124"><b> City /Country </b></TD>
<TD ALIGN=LEFT width="298">
<INPUT TYPE=TEXT SIZE=60 MAXLENGTH=100 NAME="city">
</TD>
</TR>
</TABLE>
<b>Message</b><br>
<TEXTAREA NAME="message" ROWS=10 COLS=66 SIZE=2000 WRAP=HARD></TEXTAREA>
<BR><BR>
<CENTER>
<INPUT TYPE=BUTTON VALUE=" Send " onClick="submission1();">
<INPUT TYPE=RESET VALUE="Reset Form"><br>
</CENTER>
</form>
</body>
</html>
on submit of this jsp i call the Servlet which is in the folder
webapps/examples/web-inf/classes/Mailservlet.java
i also write web.xml which is in the folder
\webapps\examples\WEB-INF\web.xml
i write the code as :
<web-app>
<servlet>
<servlet-name>MailServlet</servlet-name>
<servlet-class> MailServlet </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
MailServlet
</servlet-name>
<url-pattern>
MailServlet
</url-pattern>
</servlet-mapping>
</web-app>
but when i tried to run it the after submitting the page (Contact.jsp) i found one erro in the IE "The page cannot be found".
So any can help me out where i am wrong after looking the code.Too much unformatted code for me to browse through, use code tags please.
One thing struck me though:
> <url-pattern>
MailServlet
</url-pattern>
</servlet-mapping>
</web-app>should probably be:
<url-pattern>
/MailServlet //notice the /
</url-pattern>Have you tried accessing the Servlet by typing out the URL? Does that work?
Also, http://nogoodatcoding.googlepages.com/deployingaservletontomcat -
Running servlets in tomcat server
Hi,
I am not able to execute servlets in tomcat,
When i executed the program html file was running perfectly and when i click on the submit button it is displaying the following error
type Status report
message ServletCalled.class
description The requested resource (ServletCalled.class) is not available.
I followed the below procedure
I created a new directory in webapps "webapps/test".
Test directory contains
1. callservlet.html file
2. another directory Web-inf (i.e, webapps/test/Web-inf)
Web-inf directory contains
1. web.xml file
2. another directory classes (i.e, webapps/test/Web-inf/calsses)
classes directory contains
1. ServletCalled.class file
Html file code
callservlet.html
<html>
<body>
<form method=post action="/ServletCalled/ServletCalled.class">
<input type=submit value="submit">
</form>
<body>
</html>
servlet file
ServletCalled.java contains
public void doPost(HttpServletRequest req,HttpServletResponse res ){
java.io.PrintWriter out = req.getWriter();
out.println("Hi, executed");
web.xml file
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>ServletCalled</servlet-name>
<servlet-class>ServletCalled</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletCalled</servlet-name>
<url-pattern>/ServletCalled</url-pattern>
</servlet-mapping>
</web-app>
i used all the options above i changed the <url-pattern> and form tag to (<form action="/ServletCalled" method=get>)but same error persists
Please help me out in this thanks in advancethanks !! i got the solution
-
hai friends,
I am trying to execute a simple servlet in tomcat but I couldn't..
please help meCan you execute the default Servlets in Tomcat which are found in the "Examples" folder ? http://localhost:<PORT NO>/examples/
If yes then try deploying your servlet in the examples folder and find out a file called "servlet.jar " in your server and set its classpath.
I hope that will work.
Shashi -
Exception while executing JSP in TOMCAT
Hi,
I am new to Tomcat 5.0. I saved the JSP file in webapps/root folder. I have JDK1.3.1 and JRE 1.4.1. When I am executing the jsp, I am getting the following exception.
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: -1 in the jsp file: null
Generated servlet error:
[javac] Compiling 1 source file
C:\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\test_jsp.java:9: cannot access java.lang.Object
bad class file: C:\Program Files\Java\j2re1.4.1_03\lib\rt.jar(java/lang/Object.class)
class file has wrong version 48.0, should be 47.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
implements org.apache.jasper.runtime.JspSourceDependent {
^
1 error
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:83)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:315)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:406)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:463)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:442)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:430)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:274)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
If I remove JRE 1.4.1 and install previous version i.e. 1.3.1, the tomcat server is not starting. How do I proceed. I need help in executing servlets also. I copied the tools.jar file into the common/lib folder.
I am awaiting for the replies. Thanks in advance.
sampathHmmm. It seems that Tomcat is running on Java1.3, but trying to compile a JSP using Java1.4, which leads to problems.
What have you set your JAVA_HOME variables to?
Which version of Tools.jar did you copy to the common/lib folder?
How do you start up tomcat? Shortcut or service?
Copying Tools.jar is a bad thing to do in most cases (Yes, I know it told you to do that, but if it told you to format your harddrive would you do that too?) I would remove tools.jar, and see what happens then.
Good luck,
evnafets -
How to run a servlet in Tomcat 5.0 server
HI Everybody,
I want to know how to run the servlet file on my tomcat 5.0 server. that is where to place a class file and deployment details.
Thanks In ADVANCESourav_cs wrote:
I am a biginner to start servlet i get confusion to configure servlet in tomcat 5 where it should be saved in tomcat directory and how to execute that as first timeHi,
goto
tomcat 5.0\webappsnow create a folder here. this is your webapplication project name. Let's suppose it as "TestApp"
inside this create directories as follows :
TestApp
|
|-----JSP/htmls( if you have any )
|
|-----WEB-INF(File Folder)
|
|-----web.xml
|-----lib ( Directory. place all the .jar files which are required for this project(if any) )
|-----classes ( .class files. )[all of your java code should be placed here.](servlets / beans/ pojo )this is the general Directory structure of a web application. now you've to place the compiled .class file of your servlet in the "TestApp\WEB-INF\classes" directory. make sure that you've configured the servlet in Deploment Desctiptor, i.e, web.xml.
now start the server and type the url like : "http://localhost:8080/TestApp/TestServlet"
the port no. 8080 is the default port no. of tomcat. you have to give your port no. if u've modified it. and TestServlet is the <url-pattern> of your servlet.
go through some tutorials .. then you can easily know that
Diablo -
Hi ,
How to run servlets in tomcat server. I created two files html and servlet file.
Html file
callservlet.html
<html>
<body>
<form method=post action="servletcalled.class">
<input type=submit value="submit">
</form>
<body>
</html>
servlet file
servletcalled.java contains
public void doPost(HttpServletRequest req,HttpServletResponse res ){
java.io.PrintWriter out = req.getWriter();
out.println("Hi, executed");
i put the callservlet.html in webapps/examples/ and servletcalled.class was in webapps/examples/Web-inf/classes/
After starting the tomcat and running the program html file is getting exceuted but when i click on the submit button this error is prompted
type Status report
message servletcalled.class
description The requested resource (servletcalled.class) is not available.
Thanks in advanceThanks,
I created a new directory in webapps
s "webapps/test".
Test directory contains
1. callservlet.html file
2. another directory Web-inf (i.e,
webapps/test/Web-inf)
Web-inf directory contains
1. web.xml file
2. another directory classes (i.e,
webapps/test/Web-inf/calsses)
classes directory contains
1. servletcalled.class file
web.xml file contains
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>Example</servlet-name>
<servlet-class>Example</servlet-class>
</servlet>
</web-app>
-->should be: <servlet-class>servletcalled</servlet-called>
then in the <web-app> scope define this:
<servlet-mapping>
<servlet-name>Example</servlet-name>
<url-pattern>/servlets/Example</url-pattern>
</servlet-mapping>
>
thanks in advance i am working hard on that but
notable to get the solutionbtw by reading the documentation of tomcat and tutorials of jave on the java site (here), you would have known this! -
How to run a servlet in tomcat 5.0.
Hi all,
how to run a servlet in tomcat 5.0
please tell me the entire procedure....(directory structure)
step by step....hi :-)
http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets.html
or
http://www.google.com.ph/search?hl=en&q=java+servlet+tutorial&btnG=Google+Search&meta=
regards, -
Error in executing servlet JSPRunner: java.lang.NullPointerException
I have some problems with my jsp files.
I am using iAS6sp4 and iWS 6 on W2K.
I created a EJB jar file and an empty WAR file (No JSP, Servlet, just web.xml & ias-web.xml) and pack them into a ear file for deployment. It was successful.
Then I copy some jsp files to <iasinstall>/ias6/ias/APPS/<app name>/<war name>
and restart the ias and iws server.
When I try the URL: "http://myserver/NASApp/<app name>/myjsp.jsp", I got this error message from kjs.
JSPRunner: init
Exception: SERVLET-execution_failed: Error in executing servlet JSPRunner: java.lang.NullPointerException
My jsp didn't include any java code, just pure htm code. I want to give it a test. But even though I tried with a proper jsp i still got this message. pls advise.
AlanHi,
I got this working. Here are the steps that I followed and the output...
Steps
1. Deployed the helloworld application
2. Invoked the application to see if it works fine
3. Copied the myjsp.jsp to the C:\iPlanet\ias6\ias\APPS\helloworld\helloworld directory
4. Shutdown the iAS and iWS and started again
5. Invoked the .jsp file by typing http://sundts2.india.sun.com:81/NASApp/helloworld/myjsp.jsp in the browser.
Output of KJS
[16/Mar/2002 14:46:06:5] info: ENGINE-ready: ready: 10819
**********Registered ebnls interceptor ...!
[16/Mar/2002 14:46:22:4] info: --------------------------------------
[16/Mar/2002 14:46:22:4] info: JSPRunner: init
[16/Mar/2002 14:46:22:4] info: --------------------------------------
[16/Mar/2002 14:46:26:4] info: --------------------------------------
[16/Mar/2002 14:46:26:4] info: jsp.APPS.helloworld.myjsp: init
[16/Mar/2002 14:46:26:4] info: --------------------------------------
The myjsp.jsp coding is...
<HTML>
<BODY>
<H1>This is a .jsp file for testing</H1>
</BODY>
</HTML>
I believe the problem in your case must be that the .jsp file has been placed in a directory where iAS is not able to recognise. I'm sure this will help. Please feel free to raise questions on this.
Regards
Ganesh .R
Developer Technical Support
Sun Microsystems
http://www.sun.com/developers/support -
Servlet on tomcat 4.1.18
I am facing a problem of running servlets on Tomcat 4.1.18. The problem seems to be in the configuration. In the webapps folder, I created a folder greeting. In that, the WEB-Inf\classes folder has GreetingServlet.class.
webapp\greeting has index.html that has to FORM ACTION set to /greeting/servlet/GreetingServlet.
On clicking the submit button the message I get is that the resource /greeting/servlet/GreetingServlet is not found.
Can anybody help in configuring the server so that the above mentioned servlet gets recognized?
Thanks.
Amitabh.
[email protected]My application is located at %TOMCAT_HOME%\webapps.
%TOMCAT_HOME%\webapps\greeting\WEB-INF\web.xml has the following:
<web-app>
<servlet>
<servlet-name>greeting</servlet-name>
<servlet-class>GreetingServlet</servlet-class>
</servlet>
</web-app>
%TOMCAT_HOME%\webapps\greeting\index.html has the following:
<FORM ACTION="/greeting/servlet/GreetingServlet" METHOD="POST">
<P> Your name <INPUT TYPE="text" SIZE="40" NAME="name"></P>
</FORM>
Yet the problem persists.
Have I missed some point?
Help/assistance will be appreciated.
Thanks.
Amitabh.
[email protected] -
I am trying to run servlets using Tomcat. I have them working and displaying but as soon as I make a change to a servelt and re-compile and refresh the browser the change do not take effect. I have to shutdown and restart tocat. Surely this can't be right. can anyone help with correcting this problem?
Lesta,
For convenience there's a Tomcat admin console. The admin console runs through a web browser and allows you to restart an application, restart a context ect. I think you can also install or reinstall entire ears through it now.
There's some setup to do before you can use the admin console. I seem to remember there being an XML user/password file somewhere...
In a production environment you don't want to shutdown and restart the daemon like you are doing. It will just annoy the heck out of your users.
Hope this helps.
-Bryan -
Need to enable autoreload feature for servlet in Tomcat
Hello
I wants to enable autoreload feature for servlet in tomcat so that i need not to stop tomcat 4.0 web server again and again
Thankshttp://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/context.html
It is amazing what reading the manual might do for ya.
Maybe you are looking for
-
Dreamweaver MX - troubles with a pop-up menu/navbar combo
Hi all, I'm attempting to create a 4-button navigation bar, where three of the buttons produce a popup menu with links to other pages within the site onMouseOver. The navbar itself works great, but I put all of that in a template, which of course is
-
Why wont my Album Covers go into Itunes?
I just moved over from Zune and I have to recopy all my music into Itunes. With Zune all my album art work is there, in Apple 1/2 of my stuff is just written and when I go out to ask for it there is nothing there? How do
-
I want to share photos and videos of our kids with close family but have the following problems with what I've found out there so far: - Facebook: Not private enough, grandparents don't engage with it, too clunky to post to limited people regularly.
-
Butterscotch toolbar wont uninstall
I accidently installed the Buterscotch toolbar. I have deleted it from Tools|Add-ons|Extensions and in Control panel|Add Remove Programs also remove the Folder in My Programmes but it delays opening Firefox while it tries to run a script. Chrome://ta
-
3002- Error initializing printer on Linux
hi, I have problem above, when I select File -> Choose Printer in Report Builder 6i. My /etc/printcap is here: #printcap file containing the currently set up printers: #This file is written using APS library functions, developed by Corel Corporation: