Package javax.servlet.http
Hi,
i work whith Solaris 2.6
my java version is 1.3.0
The package javax.servlet.http is not a standard package?
Where he is?
I can download it?
look my error when i start weblogic server:
Servlet failed with Exception
java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
Thanks!
Download latest version of j2ee.jar from http://java.sun.com/j2ee/index.jsp
Amar.
Similar Messages
-
Package javax.servlet.http does not exist
Hello All,
A few problems here
1. My classpath doesnt seem to work.:
.;"C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar"
2. As a result, i get many errors in my simple code, but there are still a few that are not related to javac not recognizing the servlet api.
I also tried setting the classpath at the command line (event hough its temporary)
set classpath="C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar"
but the servlet package is still not recognized
I have 2 classes, one to read the database connection details from a file and another class, my servlet.
Servlet Code:
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class CustomQuery extends HttpServlet
public void init() throws ServletException
EstablishDBConnetion.establishConnection();
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
response.setContentType("text/html");
PrintWriter printer = new response.getWriter();
String title = "Result from custom query";
Statement stmt = EstablishDBConnetion.establishConnection.con.createStatement();
ResultSet rs = stmt.executeQuery("select customerID from customer");
while(rs.next())
printer.println("<html> <head><title>" + title + "</title><br><br><table border=\"0\"> <tr><td>" + rs.getString(1));
rs.close();
stmt.close();
EstablishDBConnetion.establishConnection.con.close();
Database connection code
import java.io.*;
import java.sql.*;
import java.util.StringTokenizer;
class EstablishDBConnetion
public static void establishConnection()
try
String dbDriver = "";
String dbUrl = "";
String dbName = "";
String dbUser = "";
String dbPassword = "";
String newLine = "";
BufferedReader fileRead = new BufferedReader(new FileReader("connection.txt"));
boolean readerStatus = fileRead.ready();
newLine = fileRead.readLine();
while (readerStatus)
StringTokenizer st = new StringTokenizer(newLine, ",");
while (st.hasMoreTokens())
dbDriver = st.nextToken();
dbUrl = st.nextToken();
dbName = st.nextToken();
dbUser = st.nextToken();
dbPassword = st.nextToken();
readerStatus = fileRead.ready();
Class.forName(dbDriver);
String url = dbUrl + dbName;
System.out.print(url);
Connection con = DriverManager.getConnection(url, dbUser, dbPassword);
catch (IOException e)
System.out.println("IO exception in establishConnection()");
e.printStackTrace();
catch (java.lang.Exception ex)
System.out.println("General exception in establishConnection()");
ex.printStackTrace();
public static void main(String[] args)
//EstablishDBConnetion edbc = new EstablishDBConnetion();
establishConnection();
}also, full error list below
CustomQuery.java:4: package javax.servlet does not exist
import javax.servlet.*;
^
CustomQuery.java:5: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
CustomQuery.java:7: cannot find symbol
symbol: class HttpServlet
public class CustomQuery extends HttpServlet
^
CustomQuery.java:10: cannot find symbol
symbol : class ServletException
location: class CustomQuery
public void init() throws ServletException
^
CustomQuery.java:16: cannot find symbol
symbol : class HttpServletRequest
location: class CustomQuery
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
^
CustomQuery.java:16: cannot find symbol
symbol : class HttpServletResponse
location: class CustomQuery
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
^
CustomQuery.java:16: cannot find symbol
symbol : class ServletException
location: class CustomQuery
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
^
CustomQuery.java:19: package response does not exist
PrintWriter printer = new response.getWriter();
^
CustomQuery.java:24: cannot find symbol
symbol : variable establishConnection
location: class EstablishDBConnetion
Statement stmt = EstablishDBConnetion.establishConnection.con.createStatement();
^
CustomQuery.java:39: cannot find symbol
symbol : variable establishConnection
location: class EstablishDBConnetion
EstablishDBConnetion.establishConnection.con.close();
^
10 errors
I appreciate your help
Message was edited by:
paulchwd
null
Message was edited by:
paulchwdThe library is in tomcat/common/lib, not in tomcat/lib.
-
Error: package javax.servlet.http does not exist
Hi all,
How do I import javax.servlet?
package com.example.web;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class BeerSelect extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html");
PrintWriter out = response.getWrite();
out.println ("Beer Selection Advide<br>");
String c = request.getParameter("color");
out.println ("<br>Got beer color " + c);
}What does this error mean? The error message:
Compiling 1 source file to C:\Program Files\Apache Software Foundation\MyProjects\J2EE\build\classes
C:\Program Files\Apache Software Foundation\MyProjects\J2EE\src\com\example\web\BeerSelect.java:3:
package javax.servlet does not exist
import javax.servlet.*;
C:\Program Files\Apache Software Foundation\MyProjects\J2EE\src\com\example\web\BeerSelect.java:4:
package javax.servlet.http does not exist
import javax.servlet.http.*;
C:\Program Files\Apache Software Foundation\MyProjects\J2EE\src\com\example\web\BeerSelect.java:7:
cannot find symbol
symbol: class HttpServlet
public class BeerSelect extends HttpServlet {
C:\Program Files\Apache Software Foundation\MyProjects\J2EE\src\com\example\web\BeerSelect.java:8:
cannot find symbol
symbol : class HttpServletRequest
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest request,
C:\Program Files\Apache Software Foundation\MyProjects\J2EE\src\com\example\web\BeerSelect.java:9:
cannot find symbol
symbol : class HttpServletResponse
location: class com.example.web.BeerSelect
HttpServletResponse response)
C:\Program Files\Apache Software Foundation\MyProjects\J2EE\src\com\example\web\BeerSelect.java:10:
cannot find symbol
symbol : class ServletException
location: class com.example.web.BeerSelect
throws IOException, ServletException {
6 errors
BUILD FAILED (total time: 0 seconds)Thank you.Hi,
The file servlet-api.jar / servlet.jar is not available in your classpath.
To compile an Servlet you need the jar file to be in classpath.
The jar file can be found in your webserver / application server lib folder.
Regards,
Zack -
Package javax.servlet does not exist, package javax.servlet.http does not
Dear All,
I am a newbie to JAVA.
I installed JDK1.6.0_04, then NetBeans IDE 6.0
I tried compiling an example servlet, but got this error message:
package javax.servlet does not exist, package javax.servlet.http does not exist
I tried locating these packages, but in vain. I also tried setting the CLASSPATH to many values, still it did not work.
Can anyone, please, help me with this.
Should I be able to see/locate these packages, do I have to download them?
Thank you very much.davidgoodman wrote:
Dear All,
I am a newbie to JAVA.
I installed JDK1.6.0_04, then NetBeans IDE 6.0
I tried compiling an example servlet, but got this error message:
package javax.servlet does not exist, package javax.servlet.http does not exist
What servlet/JSP engine do you plan to deploy to? Tomcat, perhaps?I think it's Tomcat (C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14). Are there other engines that come with NetBeans IDE 6.0 (when I downloaded NetBeans, I chose ALL)
>
If so, you'll need to put the servlet JAR in your CLASSPATH. (servlet-api.jar for Tomcat 5.5 and earlier, servlet.jar for 6.0 >and later.)
I tried locating these packages, but in vain.
You won't find them until you realize that you have to deploy that servlet someplace.How to deploy?
I also tried setting the CLASSPATH to many values, still it did not work.
See above. What were you planning to set CLASSPATH to?First I set to:
C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib (because I found jar named servlet-api.jar in this folder)
Later I added this:
C:\Program Files\Java\jdk1.6.0_04\lib (out of trial-and-fail)
Finally I added some paths that lead to a library such as
C:\Program Files\glassfish-v2\lib
C:\Program Files\glassfish-v2\lib\ant\lib
Can anyone, please, help me with this.
Should I be able to see/locate these packages, do I have to download them?
You have to get a servlet/JSP engine. Step 1.Thank you for your help -
Why I got package javax.servlet.http do not exist
I have package javax.servlet.http do not exist problem, can anyone tell me why?
Thank youHi all
Thank you for all kinds of replies. It is Windows problems. but I got a new questions here
1) it seems I don't need to including
install_dir\common\lib\jsp-api.jar in classpath!!
2) when I try servletUtilities,
from http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Configure-Tomcat
I got error
HelloServlet3.java:23: cannot resolve symbol
symbol : variable ServletUtilities
location: class coreservlets.HelloServlet3
out.println(ServletUtilities.headWithTitle(title) +
^
1 error
both my HelloServlet3 and servletUtilities under
WEB-INF\classes\coreservlets
thank you -
Package javax.servlet.http does not exists
Hi,
I am new to J2EE and am writing my first servlet. I tried to compile a servlet I wrote and got the following error.
"package javax.servlet.http does not exists".
What do i do to correct this error?
Also is there any links which has a complete servlet tutorial.
Please advice
ThanxMost probably you need to include the servlet-api library in your classpath when compiling.
You should find this file in the lib directory of your container.
It will be called servlet-api.jar (Tomcat) or j2ee.jar (Suns J2EE server) or something along those lines.
The j2ee tutorial is a decent place to start learning about servlets...
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/
Good luck,
evnafets -
Package javax.servlet.http does not exist & package javax.servlet does not
Hello!
I am trying to compile this file:
/* serv2.java 29 Sep 04 */
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class serv2 extends HttpServlet
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("<HTML><HEAD><TITLE>Sample Servlet</TITLE></HEAD>"+'\n'+
"<BODY BGCOLOR='lightgreen'>"+'\n'+
"<H1 ALIGN=CENTER>Heading</H1>" + '\n' +
"<P><H2 ALIGN=CENTER>Message</H2");
out.println("</BODY></HTML>");
}And I am getting this error message:
C:\Program Files\Apache Tomcat 4.0\webapps\ROOT\WEB-INF\classes\serv2.java:4: package javax.servlet does not exist
import javax.servlet.*;
^
C:\Program Files\Apache Tomcat 4.0\webapps\ROOT\WEB-INF\classes\serv2.java:5: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
C:\Program Files\Apache Tomcat 4.0\webapps\ROOT\WEB-INF\classes\serv2.java:7: cannot resolve symbol
symbol : class HttpServlet
location: class serv2
public class serv2 extends HttpServlet
^
C:\Program Files\Apache Tomcat 4.0\webapps\ROOT\WEB-INF\classes\serv2.java:9: cannot resolve symbol
symbol : class HttpServletRequest
location: class serv2
protected void doPost(HttpServletRequest req, HttpServletResponse res)
^
C:\Program Files\Apache Tomcat 4.0\webapps\ROOT\WEB-INF\classes\serv2.java:9: cannot resolve symbol
symbol : class HttpServletResponse
location: class serv2
protected void doPost(HttpServletRequest req, HttpServletResponse res)
^
C:\Program Files\Apache Tomcat 4.0\webapps\ROOT\WEB-INF\classes\serv2.java:10: cannot resolve symbol
symbol : class ServletException
location: class serv2
throws ServletException, IOException
^
6 errors
Tool completed with exit code 1
I have tried setting CLASSPATH lib/servlet.jar but it still will not work.
Please help me!!!Please check this page,
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html
and also
serv2 -> set it to Serv2
another nice to read :-)
http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html
+"Class names should be nouns, in mixed case with the first letter of each internal word capitalized"+
Another thing,
Put your class in a package, thanks =)
regards and goodluck,
jie -
and a bunch of "cannot resolve symbol".
I do have servlet-api.jar in the classpath.
This is ApacheTomcat 5.5.25, JVM version 1.5.0_04-b05,
javac -J-version
java version "1.4.2_13"
What am I missing?The environment variabele $classpath is only used by the java runtime, not by the java compiler.Are you certain of that Balusc?
Granted I don't use the command line to compile things much, but I'm pretty sure it uses the CLASSPATH environment variable if you don't specify a -cp or -classpath.
Can you please show the
- error message/stacktrace
- value of CLASSPATH environment variable
- command line you are using to compile the class
- an excerpt from the class itself.
Cheers,
evnafets -
Javax.servlet.http.* package does not exist ?
i am using j2sdk which does not include servlets, so in the forums i found that including servlet.jar file in jdk1.6.0\jre\lib\ext javax.servlet.* was included but javax.servlet.http did not ..... now this is strange either both do not work or both work. here is the code
import javax.servlet.*;
import javax.servlet.Http.*;
class login
error is package javax.servlet.Http.*; does not exist.Dear,
javax.servlet is one of the J2EE (Java Enterprise Edition) packages that is not included in the J2SE (Java Standard Edition) , so that one used for developing server side application.
I hope this help.
Regards. -
Package javax.servlet does not exist - settings appear to be correct
laugh as I write this post...it's hardly a "new topic."...but everything seems set just as it should be...
Okay...I'm a seasoned programmer in every language but JAVA. Here's the issue...every time I try to use the Core Servlets book/website by Marty Hall and Larry Brown I get hung up on the packages. This time, I downloaded and followed step by step what the website said to do...it was even preconfigured for me! Alas...I am getting the following compliation errors on a "simple packagless" program with NetBeans:
Compiling 1 source file to C:\Servlets+JSP\HelloServlet\build\classes
C:\Servlets+JSP\HelloServlet\src\helloservlet\HelloServlet.java:2: package javax.servlet does not exist
import javax.servlet.*;
C:\Servlets+JSP\HelloServlet\src\helloservlet\HelloServlet.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
C:\Servlets+JSP\HelloServlet\src\helloservlet\HelloServlet.java:13: cannot find symbol
symbol: class HttpServlet
public class HelloServlet extends HttpServlet {
C:\Servlets+JSP\HelloServlet\src\helloservlet\HelloServlet.java:14: cannot find symbol
symbol : class HttpServletRequest
location: class HelloServlet
public void doGet(HttpServletRequest request,
C:\Servlets+JSP\HelloServlet\src\helloservlet\HelloServlet.java:15: cannot find symbol
symbol : class HttpServletResponse
location: class HelloServlet
HttpServletResponse response)
C:\Servlets+JSP\HelloServlet\src\helloservlet\HelloServlet.java:16: cannot find symbol
symbol : class ServletException
location: class HelloServlet
throws ServletException, IOException {
6 errors
BUILD FAILED (total time: 0 seconds)
These are my environment settings (note that the JAVAX package is located under the src folder in Java)
Catalina Home:
C:\apache-tomcat-6.0.10
CLASSPATH:
C:\apache-tomcat-6.0.10\lib\servlet-api.jar;
C:\apache-tomcat-6.0.10\lib\jsp-api.jar;
C:\apache-tomcat-6.0.10\lib\el-api.jar;
C:\Servlets+JSP;..;..\..;
C:\Program Files\Java\jdk1.6.0_03\src
JAVA_HOME
C:\Program Files\Java\jdk1.6.0_03
Path:
C:\Program Files\Java\jdk1.6.0_03\bin;%PATH%
Any ideas (excluding the one that maybe I should let my hair grow out, put on some tackey shorts and sandles and start palying an instrument in the streets of Austin for living?)cabkats wrote:
You are then suggesting that I make the corrections directly to the files in apache using notepad instead of using the envir. variables?No I am not suggesting that. I am suggesting that you need to read the documentation about the product(s) and set them up the way they require, rather than blindly think that the CLASSPATH environment variable is some magical entity.
I will try this, but I was hoping that since my IDE auto configured (with exception to java_home) that I would not have to do this. I wil give it try....thanks for the suggestion.See, you're using an IDE. Like I mentioned, IDEs do not use the CLASSPATH environment variable. You need to set up your project in your IDE in such a way that it knows what the dependent jars are. I'm sure there's a way to add jars to your project's dependencies. -
ATMTag.java:5: package javax.servlet does not exist
My j2ee jdk1.4.2 is not supporting javx package.
i already set all pathh and class path.
anybody can help me.
details are given below ::
C:\AVA\J2EE Programs\JSP\JSPCustomTag>javac ATMTag.java
ATMTag.java:5: package javax.servlet does not exist
import javax.servlet.*;
^<br>
ATMTag.java:6: package javax.servlet.http does not exist
<br>
import javax.servlet.http.*;
<br>
ATMTag.java:18: cannot resolve symbol
symbol : class TagSupport
location: class ATMTag
public class ATMTag extends TagSupport{
<br> ^
ATMTag.java:29: cannot resolve symbol
symbol : class JspTagException
location: class ATMTag
public int doStartTag() throws JspTagException{
<br> ^
ATMTag.java:31: cannot resolve symbol
symbol : class JspWriter
location: class ATMTag
<br> JspWriter out =pageContext.getOut();
^
ATMTag.java:31: cannot resolve symbol
symbol : variable pageContext
location: class ATMTag
<br> JspWriter out =pageContext.getOut();
^
ATMTag.java:56: cannot resolve symbol
symbol : variable pageContext
location: class ATMTag
pageContext.getOut().write(str);
<br> ^
ATMTag.java:60: cannot resolve symbol
symbol : variable EVAL_PAGE
location: class ATMTag
return EVAL_PAGE;
^
8 errorsWhen compiling servlets etc, you need to include in your classpath a jar file with all the javax.* classes defined in it.
For Tomcat this is called servlet.jar and is in (I think) [TOMCAT_HOME]/shared/lib or /common/lib
For J2EE 1.4 Server, the jar is [J2EE_HOME]/lib/j2ee.jar
Where the _HOME directory is the directory where you installed J2EE.
Include this jar file in your classpath when compiling.
Good luck,
evnafets -
Javax.servlet.http.* error
I am trying to compile a file, but got the error message "package javax.servlet.http does not exist",
"import javax.servlet.http.*"
It seems to me that this particular package is missing. how and where exactlly do I get this particular package and make it to work??
thanksAs you are using the package I assume that you're targetting a servlet engine (such as Tomcat) or a J2EE server. The package is in servlet.jar which is part of the binary release of the container that you are using.
You can download containers from the following links:
http://java.sun.com/products/servlet/index.html
http://jakarta.apache.org/tomcat/index.html -
Hi
I am trying to compile one servlet code using commancd prompt and i get
package javax.servlet.http does not exist import javax.servlet.http.HttpServlet;
error for following code
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
public class SampleServlet extends HttpServlet
public void saveToSession(HttpServletRequest request)
String testparam = request.getParameter("testparam");
request.getSession().setAttribute("testAttribute", testparam);
please help meTry giving servlet..jar path in the class path variable
-
Cannot Import javax.servlet.* and javax.servlet.http.*
Hello,
I am a University Student and now doing a project using Servlet and JSP
I have installed WinXP and Tomcat 5.0 on my computer
When I compile the servlet , there are error messages "package javax.servlet does not exist" and "package javax.servlet.http does not exist" coming out.
I have set the classpath already
i.e. %CATALINA_HOME%\common\lib\servlet-api.jar;%CATALINA_HOME%\common\lib\jsp-api.jar
( Of course "%CATALINA_HOME%" = my folder that install the Tomcat )
Can Anybody Explain what is happening and suggest a solution to me?
Please give a hand.When you ran that command, what happened? Let javac.exe tell you the right answer.
I'd advise two things:
(1) Installing any s'ware in a directory whose name contains spaces (e.g., "Apache Software Foundation" or "Tomcat 5.0") is a very bad idea, IMO. I'd reinstall to a new directory.
(2) Your HelloServlet.java servlet probably doesn't have a package statement in it. Tomcat 5.0 won't play nicely with servlets or beans that aren't in packages. I'd add one and use the -d . option on javac.exe to make sure it created the package directory structure for me. -
Package javax.servlet doest not exist
Hi,
I just started to learn servlets. But when I am trying to compile my first program, which is HelloServlet , I am getting compilation error saying that Package javax.servlet does not exist, package javax.servlet.http does not exist.
I am using j2sdk version 1.4.2_04 and Tomcat 5 .
I set the classpath and it looks like this
set CLASSPATH=.; C:\ServletPrograms;C:\Tomact\common\lib\servlet-api.jar;C:\Tomcat \common\lib\jsp-api.jar
I stored my servlet program in C:\ServletPrograms directory.
Can any body please help with this?????I just started to learn servlets. But when I am trying to compile my first program, which is HelloServlet , I am getting compilation error saying that Package javax.servlet does not exist, package javax.servlet.http does not exist.The OP is attempting to compile.
I set the classpath and it looks like this
set CLASSPATH=.; C:\ServletPrograms;C:\Tomact\common\lib\servlet-api.jar;C:\Tomcat \common\lib\jsp-api.jarThe OP is also attempting to set the classpath but notice that here the path to the servlet-api.jar has Tomcat mis-spelled. Is this the actual classpath or a typo when posting the question?
Maybe you are looking for
-
Hi there, I have a scheduled backup job which set to run daily, for some reason or another it has failed and it's current status is skipped and has been so for the last couple of days. I have tried to stop the job, but it sill remains there in the sa
-
Hide "Activity_Type" in a request for Advance Payment
Hello experts, How can I hide the field "Activity Type" in a request for Advance Payment on SAP Gui? Thanks in advance!
-
Spotlight mp3 search results - showing song title only
Hi, Since upgrading to 10.9 spotlight only shows the tag of the songs instead of the filename. this is really annoying. Is there any way to fix this? Thanks, Udi
-
Hi All., I have created the Operating concern with some characteristics & value fields. Now my client want to add two more characteristics to the operating concern by removing the existing ones. when i am trying to add them it is not happening. Is th
-
Identify the email sent by mobile phones using Transport Agent?
Hi, Is there a way using Exchange Transport SDK to identify whether an email is sent by mobile device or not? We have a business proposition, where we are going to build a transport agent based on this identification. Thanks in anticipation. Regards,