Compiling a servlet
Hi,
I am using jakarta-tomcat-4.0, to which jar file I have to set the classpath inorder to compile a servlet program.
Thanks
<TOMCAT>\common\lib\servlet.jar
Similar Messages
-
How to Compile/Run servlet in Tomcat 4.1
Hi All,
iam trying to compile my servlet program in tomcat4.1.. but its showing an error
in the import statement..
UN SOLVABLE SYMBOL... but the import ststement is correct...
can any one help ... is there i have to set any path for compiling/running the servlet...
Thanks in Advicehi thanks for your reply
i have loaded tomcat4.1 exe -- for windows i am starting the tomcat server by clicking from the start menu..
i dint set any env variable .. tell me how to set...
regards
ijay -
Create problem when compiling the servlet
hi,
i got a problem when i compile a servlet
when i try to compile the servlet, it shows that it could
not found the classes like httpservlet, etc.
means the classes of the servlet
i am using the j2sdk1.4.1 edition,
i had include the javax.servlet.*; in the program
please tell me what can be the problem & especially any solution for thatthe javax.servlet package and it's sub packages (javax.servlet.http, javax.servlet.jsp, javax.servlet.jsp.tagext) are not included with the Standard Edition. These packages are part of the Enterprise Edition. Check out this link for download:
http://java.sun.com/j2ee/sdk_1.3/ -
Can I complie a servlet with javac?
Im a new user, when i try to compile a servlet from javac myservlet.java
The compiler send several errors, it doesn't recognise the class of servlets.
My Enviroments' vars are:
PATH = C:\JDK1.4\BIN
CLASSPATH = .;C:\JBuilder8\thirdparty\jakarta-tomcat-4.1.12-LE-jdk14\common\lib\
I don't know if i'm doing wrong
I hope your answersYou need to add sevlet.jar to your classpath, which is located in TOMCAT_HOME/common/lib
-
Compiling a Servlet that uses JavaBean
I have a servlet that will get data from a JavaBean which is created before in a jsp file. While I trying to compile the servlet I am getting this message:
--------------------Configuration: JDK version 1.3 <Default>--------------------
Command : "C:\jdk1.3\bin\javac.exe" -d "C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes" C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes\MyServlet.java
Directory : C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes
C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes\TasitKayitGirisi.java:19: cannot resolve symbol
symbol : class SimpleBean
location: class MyPackage.SimpleBean
SimpleBean simpleBean = (SimpleBean) session.getAttribute
^
("simpleBean");
C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes\MyServlet.java:19: cannot resolve symbol
symbol : class SimpleBean
location: class MyPackage.SimpleBean
SimpleBean simpleBean= (SimpleBean) session.getAttribute("simpleBean");
^
2 errors
Process completed.
Where is the problem. SimpleBean is successfully being initializing in my jsp file. But I couldn't compile my servlet that will get data from that bean. Both my servlet and bean are in the same package. I am using JCreator to compile servlets. I think the problem is the compile string that JCreator uses. Can you help me. Thx in advance.Looks like an import Problem.
The Compiler is not able to "see" the SimpleBean Class.
Take care of the Classpath and your imports.
Happy Coding. :-) -
I am trying to compile a servlet using the import javax.servlet.*;
import javax.servlet.http.*; packages. But the only thing I keep getting is :
BasicServlet.java:1: package javax.servlet does not exist
import javax.servlet.*;
^
BasicServlet.java:2: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
BasicServlet.java:6: cannot resolve symbol
symbol : class HttpServlet
location: class BasicServlet
public class BasicServlet extends HttpServlet
I have included the servletapi2_1_1-win package from the sun site containing the servlet.jar in my classpath. Still it refuses to compile. Besides does anybody know how to compile using the servlet packages available in Tomcat or j2ee, both of which I have on my machine , but can't figure what to include.
Please help.
^have you actually included the servlet.jar file in your classpath or just the directory, as you need to explicity declare jar files in the classpath...
javac -classpath %CLASSPATH%;C:\[servlet-jar-path]\servlet.jar Servlet.class -
Errors when compiling a servlet
I wrote a servlet named ShowRequestHeaders.java. Before I installed JDeveloper 3.2, I had already installed both standard 1.3 and enterprise 1.2.1 JDK. The source code looks like this:
package coreservlets;
import statement....
public class void Classname extends
HttpServlet {
But I got an error message:H:\Program Files\Oracle\JDeveloper 3.2\myprojects\welcome\ShowRequestHeaders.java
Error: (17) class HttpServlet not found in class coreservlets.ShowRequestHeaders.
what's wrong with this?
nullYou don't have the Servlets library in the JDeveloper project.
Open JDeveloper with the project having the servlet.
Open Project properties from menu Project|Project properties
Click on the Libraries tab.
Click Add
From the list choose "Servlet SDK" and click OK
Click OK in the project properties window.
Now compile your servlet.
raghu -
This may be a dumb question, but is there any way to compile a servlet without using ant?
nevermind, I got it...
-
Hi, i have a problem to compile a servlet, i will try to explain my problem easily...
i have a JavaBena class int he directory.....C:\Programmi\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\WEB-INF\classes......and i have compiled it by DOS commands, everyhting has gone well!
i have a Servlet class in the same directory where it situated the JavaBean. i compile the Servlet as well as i have done with the Javabean, by DOS commans, including the Tomcat servlet api.
this is the command which i use to compile the servlet.......javac ServletRegistraUtente.java -classpath "C:\Programmi\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar".....
but everything i get this error...
C:\Programmi\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\WEB-INF\classes>javac ServletRicercaUtente
.java -classpath "C:\Programmi\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar"
ServletRicercaUtente.java:20: cannot find symbol
symbol : class BeanRicercaUtente
location: class ServletRicercaUtente
^
ServletRicercaUtente.java:20: cannot find symbol
symbol : class BeanRicercaUtente
location: class ServletRicercaUtente
BeanRicercaUtente m_BeanRicercaUtente = new BeanRicercaUtente();
^
2 errors
C:\Programmi\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\WEB-INF\classes>
these are the 2 classes....
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import JavaBean.BeanRicercaUtente;
public class ServletRicercaUtente extends HttpServlet
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
ServletContext sc;
RequestDispatcher rd;
try
BeanRicercaUtente m_BeanRicercaUtente = new BeanRicercaUtente();
request.setAttribute("m_BeanRicercaUtente", m_BeanRicercaUtente);
String codiceFiscale = request.getParameter("codice");
m_BeanRicercaUtente.effettuaRicerca(codiceFiscale);
sc = getServletContext();
rd = sc.getRequestDispatcher("/risposta.jsp");
rd.forward(request, response);
catch(Throwable theException){}
import java.sql.*;
public class BeanRicercaUtente
String nome, cognome, indirizzo, telefono;
public void effettuaRicerca(String codiceFiscale)
try
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://.................";
Connection con = DriverManager.getConnection(url);
Statement cmd = con.createStatement();
String qry = "SELECT ..................";
ResultSet res = cmd.executeQuery(qry);
while (res.next())
cognome = res.getString(1);
nome = res.getString(2);
indirizzo = res.getString(3);
telefono = res.getString(4);
res.close();
cmd.close();
con.close();
catch (SQLException e)
e.printStackTrace();
catch (ClassNotFoundException e)
e.printStackTrace();
i would be glad to get help about it...! :) thanks!i am sorry, but in the first class i have not written "import JavaBean.BeanRicercaUtente;"
i have only these imports...
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*; -
Compiling Java Servlet with Depricated Methods
I have a problem of compiling Java servlets that contain depricated methods. If you compile against modern version of servlet.jar I see depricated methods error messages and if I use a very old servlet.jar it cannot find newer methods. What is is the best solution in this case?
Thank you,
Boris.The best thing to do would be compile your code with the -depreciated option to find which methods have been depreciated and the refactor your code to remove them.
The next best thing is to ignore the messages (they are warnings not errors) and your code should still work -
Compiling a servlet with utility class
Hello,
I am having trouble compiling a servlet that uses a utility class.
The compiler doesn't seem to recognize the utility class for some reason.
my classpath is set to:
.;C:\ServletDevel;C:\Program Files\Apache Software Foundation\common\lib\servlet-api.jar
the error:
Cannot find symbol: ServletUtilities
the servlet code:
package coreservlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/** test the use of packages and utilities on the server */
public class helloservlet3 extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String title = "Hello (3)";
out.println(ServletUtilities.headWithTitle(title) +
"<body bgcolor=\"#FDF5E6\">\n" +
"<h1>" + title + "</h1>\n" +
"</body></html>");
the utility class:
package coreservlets;
import javax.servlet.*;
import javax.servlet.http.*;
/** time saving static methods */
public class ServletUtilities {
public final static String docType =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">";
public static String headWithTitle(String title){
return (docType + "\n" + "<html>\n" +
"<head><title>" + title + "</title></head>\n");
any help wouldbe greatly appreciated.Nope still getting an error
helloservlet3.java:17:cannot find symbol
symbol : class ServletUtilities
location: package coreservlets
out.println(coreservlets.ServletUtilities.headWithTitle(title) +
thanks for the help, i'll keep on trying to figure it out. -
Hello,
I recently installed Tomcat 4.1.24 and I am trying to compile a servlet but with no success. The error I get is package javax.servlet does not exist. I have set up jdk1.3.1-3 and the environment paths. I have been successful in compiling regular java applications. I am currently just using the dos prompt and command line c:\javac somefile.java
When I tried to compile a servlet, I ran into the javax.servlet error so I found a javax.jar file and added it to the jdk1/3/1-3\lib directory but the compile still fails.. I even tried to add it to the environment path but that still doesn't work...
could someone tell me where I would need to add the javax.jar file? and what adjustment I need to make to be able to compile servlets?
thanks in advance for any help
gjcat777You need to get J2EE (Java 2 Enterprise Edition). Download it and install it. It's basically a couple of JAR files that you need to use. Under $J2EE_HOME/lib there is a file called J2EE.jar Include that JAR file into your project and carry on with your servlet development.
-
Iam not able to compile a servlet.I have included the servlet.jar in my classpath.
My java compiler path is c:\jdk1.3 and JWS path is d:\jws2.0
I get "Unable to resolve symbol" error which points to HttpServlet and javax.servlet.
Can anybody help me in this.the following is the code in build.xml
<? xmlversion="1.0"?>
<project name=" test" default="compile" basedir=".">
<property name="src" value="."/>
<property name="build" value="build"/>
<target name="init">
<mkdirdir="${build}"/>
</target>
<target name="compile" depends=" init">
<!- - Compile the java code - ->
<javac srcdir="${src}" destdir="${build}"/>
</target>
</project>
while building it says "The processing information
must begin with the name of the target"
what does it mean and where i have done mistake.
please clarifyIs that code exactly copied and pasted from your build file? If so, you will need to make some modifications:
1. It looks like you have a space between the "?" and "xml" on the first line. There cannot be a space here. But you do need a space between "xml" and "version". So change your code to look like this:
<?xml version="1.0"?>2. You have an extra space in your <project> element's "name" attribute. There should not be a space here. Change this line to look like this:
<project name="test" default="compile" basedir=".">
// ^
// |
// yours had a space hereThere are several places in your build file where you have spaces that should not be there. Go through the file and remove the spaces (such as in the line depends=" init").
Let me know if that changes anything for you. Oh, and one more thing -- make sure you are in the same directory as your build.xml file! Keep at it, you will get it. -
What's the easiest way to compile a servlet?
What on earth is the easiest way to compile a servlet? I have ant and I know how to use it, but there has to be an easier way. I write my programs in Textpad and it'll only spit out errors when i try to compile:
C:\projects\WEBDEV\merchandiseServlet.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
C:\projects\WEBDEV\merchandiseServlet.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
C:\projects\WEBDEV\merchandiseServlet.java:15: cannot resolve symbol
symbol : class HttpServlet
location: class merchandiseServlet
public class merchandiseServlet extends HttpServlet
^
C:\projects\WEBDEV\merchandiseServlet.java:21: cannot resolve symbol
symbol : class HttpServletRequest
location: class merchandiseServlet
protected void doGet(HttpServletRequest request, HttpServletResponse response)
^
C:\projects\WEBDEV\merchandiseServlet.java:21: cannot resolve symbol
symbol : class HttpServletResponse
location: class merchandiseServlet
protected void doGet(HttpServletRequest request, HttpServletResponse response)
^
C:\projects\WEBDEV\merchandiseServlet.java:22: cannot resolve symbol
symbol : class ServletException
location: class merchandiseServlet
throws ServletException, IOException {
^
I have my JAVA_HOME variable set to C:\j2sdk1.4.1_01 and my J2EE_HOME set to C:\j2sdkee1.3.1 and that is exactly where each are installed. How would a person compile a servlet say.. on the command line? It seems there would be an easier way than having to do a build file and all that. Any help would be greatly appreciated. I've written a lot of stuff that works great but for some reason this stuff is giving me fits. thanks in advanceC:\projects\WEBDEV>javac -classpath "C:\j2sdk1.4.1_01\bin; C:\j2sdkee1.3.1\bin;
C:\j2sdkee1.3.1\lib\j2ee.jar" merchandiseServlet.java
merchandiseServlet.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
merchandiseServlet.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
I got 7 total errors that time, more than before, all of them dealing with packages in the j2ee. The classpath is 100% correct for the way I installed everything; I have checked it about three hundred times. Could htere be some other small detail I missed? -
Help compiling BookStore SERVLETS tutorial classes
I am new to Java. Please be patient with my errors. I need help with compiling the servlets given as part of the SERVLET tutorial. I have previously installed JDK1.3.1.01. I have also downloaded the JSDK2.1 as part of the tutorial. As part of the tutorial several servlet classes were provided. Almost all of them have these import statements.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
However, the javac is unable to compile the classes. I think it is because javax.servlet is installed under /root/jsdk and JDK is installed under /usr/java/jdk1.3/bin. I can find the javax directory under /root/jsdk but not under /usr/java. I tried giving the classpath option to javac as:
javac -classpath /root/jsdk BookStoreServlet.java
But it did not work.
I believe once the servlet classes are compiled it will be possible to view them from the JSDK browser. I was able to successfully start the jsdk browser with startserver script given with the distribution. And the example SnoopServlet worked fine.
In summary, I believe the authors of the tutorial left out the details of compiling the classes and viewing from browser. I could be wrong about it.
I will appreciate any help from the users of the tutorial and anyone who knows servlets.
Many thanks.
Murthyi found this info on how to set the classpath in linux
http://java.sun.com/products/jdk/1.2/docs/tooldocs/sola
is/classpath-linux.htmlThanks imp-cat. I could compile the BookStoreServlet.java into its corresponding class. I get the following error when I try to run it. What should I do? Thanks. Regards. Murthy
java BookStoreServlet
Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
Maybe you are looking for
-
Call Logs do not show up on my Q10
Hi Friends, Call logs do not show up even after recieving/dailing calls. When i open the call log page, it shows blank page. Please help; Did i miss anything to enable. Thank you
-
Hello, I have burned iTunes purchased video's to a DVD. It will not play on my DVD player but will on my iTunes. I suspect that DRM is causing this issue. I have tried this before with my media player and hard drive and that is how I came accross DRM
-
Hi What is the main difference between a purchase order and a scheduling agreement ? regards, senthil.
-
Fillable form Wind mitigation reports
Hello I am trying to use my android tablet for inspection purpose.I am showing an example video NEW WIND MIT 061813 - YouTube of what the form should look like that is the fillable one. Then I am also merging properties (House) information that i ge
-
Hello everyone- I have a need to track when data is posted to an account for the first time within certain departments. Individual departments are created as a combination of three dimensions: Company, LOB, and Entities. For example, I wish to track