Unable to compile Servlet
First I installed the tomcat server in C:\apache-tomcat-6.0.14 directory.
Then I created a system variable CATALINA_HOME with the value C:\apache-tomcat-6.0.14.
Then I created another system variable JAVA_HOME with the value C:\Program Files\Java\jdk1.6.0.14
Then I created another environment variable CLASSPATH with the value C:\apache-tomcat-6.0.14\lib\servlet-api.jar
Then I created my servlet file Servlet_LifeCycle.java under the folder C:\apache-tomcat-6.0.14\webapps\demo-examples. The demo-examples folder was created by me.
To compile my servlet program I did the following:
C:\apache-tomcat-6.0.14\webapps\demo-examples>javac Servlet_LifeCycle.java
But the compilation failed totally.
View Answers
January 25, 2011 at 4:44 PM
Hi Friend,
Follow these steps:
1)create a servlet.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<html>");
pw.println("<head><title>Hello World</title></title>");
pw.println("<body>");
pw.println("<h1>Hello World</h1>");
pw.println("</body></html>");
}
}
2)Go to the webapps folder of your apache tomcat and create a web application folder but it should having an appropriate name like examples.
3)Create web.xml and classes folder inside the WEB_INF folder of web application folder assuming examples.
4)Copy the servlet to the classes folder.
5)Edit the web.xml to include servlet?s name and url pattern.
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
6)Compile your servlet.
7)Run Tomcat server by clicking the startup.bat file. This is located inside the bin folder of apache tomcat.
8)Open the browser and type the following url:
http://localhost:8080/webapplicationfoldername/servletname
For more information, visit the following link:
http://www.roseindia.net/servlets/introductiontoconfigrationservlet.shtml
Thanks
Related Tutorials/Questions & Answers:
Unable to compile ServletUnable to
compile Servlet First I installed the tomcat server in C... was created by me.
To
compile my
servlet program I did the following:
C:\apache...\
servlet-api.jar
Then I created my
servlet file
Servlet_LifeCycle.java under
unable to compile class file - JSP-Servletunable to
compile class file I wrote database connection in jsp file. I have form in html. In html form i put drop down list box in that form... in that dropdown list box. Hi,
dynamic bombobox in
servlet Advertisements
Unable to compile class for JSP - WebSevicesUnable to
compile class for JSP org.apache.jasper.JasperException:
Unable to
compile class for JSP
When I am trying to access a java file kept under src folder under a package from a jsp page placed under web directory, I am
unable to run servlet-mapping>
6)
Compile your
servlet.
7)Run Tomcat server by clicking...-pattern>/HelloWorld</url-pattern>
</
servlet-mapping>
6)
Compile your...-mapping>
6)
Compile your
servlet.
7)Run Tomcat server by clicking the startup.bat
servlet not compile - Java Beginnersservlet not compile Hi friend,
I am Using JDK 5.0 with that javax.servlet is not available so
i download this package and put it in the src folder,but my program
displayed "package not found" at the time of compilation
unable to connect to server - JSP-Servletunable to connect to server thank you for the program code for inserting and reteriving the image but i am
unable to deploy these two programs in weblogic/apache servers can any one help me how to do this ? Hi Friend
how to compile and run servlet program how to
compile and run
servlet program hello sir/mam i hve installed tomcat5.5 version and also have jdk1.6.0_14 installed but not able to run it or
compile i m doing it first tyme pls help me in sorting out this problem.
i hve
Unable to run the jsp page - JSP-ServletUnable to run the jsp page Expert:Naga
Hi,
I need solution this program.
In cart.jsp I printed the total amount of the products then the next page is shipping and billing details and the next page is payment details. What
compilecompile how to
compile .class files using eclipse
compilecompile how to
compile a java program using jre7
unable to execute the examplesunable to execute the examples
unable to execute the examples given for struts,ejb,or spring tutorials.Please help I am a beginner
compile errorcompile error Hello All
for example
public class A
{
static void main(String args[])
{
System.out.println("Hello World... program with Test.java and try to
compile with javac test.java an error like
unable to open the service tomcat5unable to open the service tomcat5 While trying to run tomcat server getting "
unable to open the service tomcat5" error after installed tomcat
Unable to understand Struts - StrutsUnable to understand Struts I am studying in GNIIT from NIIT.
Here... {
/**
* Processes requests for both HTTP GET and POST methods.
* @param request
servlet request
* @param response
servlet response
* @throws ServletException
unable to connect database in javaunable to connect database in java Hello Everyone! i was trying to connect database with my application by using java but i am
unable to connect... created.
6) Restart your compiler and
compile your java code.
For Inserting Data
JAVA Compile Question ?JAVA
Compile Question ? I'm
unable to
compile this file and not sure why? Can someone please help?
import java.nio.file.*;
import java.nio.file.attribute.*;
import java.nio.file.attribute.Attributes;
import
Unable to Create DSN for Unable to Create DSN for I have installed Oracle 11g R2 and JDK7 in my Computer (Windows 7 Ultimate x64) . And, I want to work with Type 1 JDBC Driver. I'm
unable to crate DNS for "Microsoft ODBC for Oracle", It gives eror
Unable to locate package openjdk-11-jdkUnable to locate package openjdk-11-jdk Hi,
I want to install open jdk 11 on ubuntu with the following command:
sudo apt install openjdk-11-jdk... information... Done
E:
Unable to locate package openjdk-11-jdk
How to resolve
unable to connect database in javaunable to connect database in java Hello Everyone! i was trying to connect database with my application by using java but i am
unable to connect...
i was using this code....
try
{
Driver d=(Driver)Class.forName
Unable to execute JSP pageUnable to execute JSP page I have written one jsp file. It contains html tags and jsp directives. I have saved the file with the extension .jsp. The tomcat server is already running onto my machine. I have saved the jsp file
Unable to use JMXMP with Knopflerfish?Unable to use JMXMP with Knopflerfish? I have a bundle which runs properly with Eclipse, then I generate the jar file and try to use it with Knopflerfish, then I get the following exception
java.net.MalformedURLException
Unable to store the image into databaseUnable to store the image into database Hello,
I have created below program and program is throwing FileNotFound exception when I pressed the submit button. The problem is coming due to JSP page is not able to find complete path
unable to insert data into database unable to insert data into database hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
unable to insert data into database unable to insert data into database hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
unable to insert data into database unable to insert data into database hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
unable to insert data into database unable to insert data into database hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
Servlet-pattern>
</
servlet-mapping>
</web-app>
6)
Compile your
servlet.
7...Servlet I want to know the steps to write a simple
servlet program... .
Hello Friend,
Follow these steps:
Put
servlet-api.jar inside
ModuleNotFoundError: No module named 'compile'ModuleNotFoundError: No module named '
compile' Hi,
My Python... '
compile'
How to remove the ModuleNotFoundError: No module named '
compile... to install padas library.
You can install
compile python with following command
ModuleNotFoundError: No module named 'compile'ModuleNotFoundError: No module named '
compile' Hi,
My Python... '
compile'
How to remove the ModuleNotFoundError: No module named '
compile... to install padas library.
You can install
compile python with following command
unable to see the output of applet. - Appletunable to see the output of applet. Sir,
I was going through the following tutorial
http://www.roseindia.net/java/example/java/applet....
u just copy that java source code and
compile that using javac
then you
How to compile and run the JSPHow to
compile and run the JSP Hi
Kindly tell me how to run and
compile JSP small Program using Tomcat as webserver.
I created small program HELLO JSP in HTML and
compile the program but it is saying Class o r interface
ServletServlet how to navigate one
servlet page to another
servlet page
compile and run java programcompile and run java program Hello, everyone!!!
I just want to ask if you anyone here knows how to
compile java file in linux specifically UBUNTU..._TO_REPLACE_1
how do I
compile and run this file using the terminal of ubuntu
how to compile programs??????????how to
compile programs?????????? "javac" is not recognised as a file name.
why??????????
Have you set your path name and class name correctly?
Anyways have a look at the following link:
Install Java
Compile time errorCompile time error Hi,
When i
compile my simple program in cmd am getting a error like
"Javac is not a recognized as an internal or external command,
operable program or batch file"
How to resolve this problem ????
compile a java classcompile a java class Hi,
Am having a class ExampleOne.java in the location C:\learn\ExampleOne.java
I want the class file to be present in C:\.
I don't want to add any package details in the code.
Is is possible to get
compile a java classcompile a java class Hi,
Am having a class ExampleOne.java in the location C:\learn\ExampleOne.java
I want the class file to be present in C:\.
I don't want to add any package details in the code.
Is is possible to get