Problem compiling servlet
I have IIS5 and Jrun and jdk1.3.1. Im trying to compile a basic servlet for the first time....
I get errors regarding the Http....here is the code.....
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
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>");
out.println("An HTML Hello World");
out.println("</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("<H1>Hello World</H1>");
out.println("</BODY>");
out.println("</HTML>");
I didnt find the servlet.jar in the Jrun dir. I'm still a newbie obviously so any more help either of you can give would be appreciated. Thanks
BTW, the code is taken from the book JSP Weekend Crash Course, so if the code is wrong then I dont know how to fix just yet.
Similar Messages
-
I have a problem compiling servlets bymeans of NetBeans IDE 3.6.
If I compile a servlet by means of another IDE, they are oK and work well with NetBeans too.
On the contrary, if I compile it bymeans of Netbeans 3.6, I get a .class which does not work. I
have realized also that for instance if the .class i get with the other IDE is 1,58 KB, if I use
NetBeans I get a .class smaller, that is 1,53 Kb.
Can you help me?
Thanks
Eugenia Marianiok
This is the servlet named Contatore.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Contatore extends HttpServlet
private int conta;
public void init(ServletConfig config) throws ServletException
conta = 0;
public void doGet(HttpServletRequest richiesta, HttpServletResponse risposta)
throws IOException, ServletException
conta++;
risposta.setContentType("text/html");
PrintWriter out = risposta.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Pagina con contatore</title>");
out.println("</head>");
out.println("<body>");
out.println("Questa pagina e' stata visualizzata");
out.println("<h1>"+conta+ "</h1> volte.");
out.println("</body>");
out.println("</html>");
out.close();
Before using the compiler of NetBeans (that is after getting Contatore.class by means of Bluej) when I use Execute I see in Internet Explorer 6.0 with win Xp Pro at the
http://localhost:8084/esempi/Contatore
Questa pagina e' stata visualizzata
1
volte.
and Contatore.class is 1,58 KB
After that I use the compiler of NetBeans when I use Execute here the error from Tomcat 5.0
I see in Internet Explorer 6.0 with win Xp Pro at the
http://localhost:8084/esempi/Contatore
HTTP Status 404 - Servlet Contatore is not available
type Status report
message Servlet Contatore is not available
description The requested resource (Servlet Contatore is not available) is not available.
Apache Tomcat/5.0.19
and Contatore.class is 1,53 KB
I hope to have said everything
I wait a help, please.
Thanks -
I've been trying to do the tutorials in a book titled Apache Jakarta-Tomcat as part of my introduction to JSP. I'm new to Java but do know the basics. I have on my machine Java 1.3, Java 1.4, Java FrameWorks 2.1 and Jython 2.1 on Win2000 Pro. So enough about my configuration. I have never worked with packages also.
I downloaded the files from the books site due to the fact I make a lot of typos when hand coding Java (I've become a pretty good debugger of my own code). But everytime I go to compile the *.java I get error messages. So below you will find HelloTag.java and beneath that the error messages that are thrown when I try and compile it. I tested other bits of *.java and have had no problem compiling them. Is there a JSP module I'm missing?
Am I doing something wrong or am I missing something from my configuration.
Marijan Madunic
package chapter2;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.TagSupport;
public class HelloTag extends TagSupport
public void HelloTag() {
// Method called when the closing hello tag is encountered
public int doEndTag() throws JspException {
try {
// We use the pageContext to get a Writer
// We then print the text string Hello
pageContext.getOut().print("Hello");
catch (Exception e) {
throw new JspTagException(e.getMessage());
// We want to return SKIP_BODY because this Tag does not support
// a Tag Body
return SKIP_BODY;
public void release() {
// Call the parent's release to release any resources
// used by the parent tag.
// This is just good practice for when you start creating
// hierarchies of tags.
super.release();
D:\Java\JDK 1.3\bin>javac HelloTag.java
HelloTag.java:3: cannot resolve symbol
symbol : class JspException
location: package jsp
import javax.servlet.jsp.JspException;
^
HelloTag.java:4: cannot resolve symbol
symbol : class JspTagException
location: package jsp
import javax.servlet.jsp.JspTagException;
^
HelloTag.java:5: cannot resolve symbol
symbol : class TagSupport
location: package tagext
import javax.servlet.jsp.tagext.TagSupport;
^
HelloTag.java:7: cannot resolve symbol
symbol : class TagSupport
location: class chapter2.HelloTag
public class HelloTag extends TagSupport
^
HelloTag.java:14: cannot resolve symbol
symbol : class JspException
location: class chapter2.HelloTag
public int doEndTag() throws JspException {
^
HelloTag.java:20: cannot resolve symbol
symbol : variable pageContext
location: class chapter2.HelloTag
pageContext.getOut().print("Hello");
^
HelloTag.java:24: cannot resolve symbol
symbol : class JspTagException
location: class chapter2.HelloTag
throw new JspTagException(e.getMessage());
^
HelloTag.java:28: cannot resolve symbol
symbol : variable SKIP_BODY
location: class chapter2.HelloTag
return SKIP_BODY;
^
HelloTag.java:37: cannot resolve symbol
symbol : variable super
location: class chapter2.HelloTag
super.release();
^
9 errorsWell, it looks like you've not got the servlet development kit JAR on your classpath. I think it'll probably be called servlet.jar on your system. Add that to the classpath if it's not already there.
Incidentally, you've bumped into one of the areas Java's slightly lenient - declaring a method that looks like a constructor:
public HelloTag() { }
public void HelloTag() { }The first is a constructor, the second is a normal method. I'm assuming you intended to have the former instead of the latter.
Anyway, hope this helps. -
Problem in Servlet Compilation & Deployment
Hi Friends,
I have problem regarding Servlet Compilation & Deployment.
At the time of compilation gives error message "import javax.servlet.* is not a recognize package.
My J2ee Server gives FATAL Error it says it should be work on JDK1.2 or later.
My JDK is :-j2sdk1.4.2_04
MY J2EE Server is:-j2sdkee1.2.1
My Servlet Runner is:-JSDK2.0
My Java Enviorment is:- Version 1.5.0 (build 1.5.0_04-b05)
Path setting is:-
Class Path=C:\j2sdk1.4.2_04\lib;C:\j2sdkee1.2.1\lib\j2ee.jar;C:\JSDK2.0\lib
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=DCL-04
ComSpec=C:\WINNT\system32\cmd.exe
Please help me and give the desired result as soon as you all can
Your's Harish
ThanksAt the time of compilation gives error message "import javax.servlet.* is not a recognize package.You have to include servlet.jar or j2ee.jar in the classpath when compiling.
My JDK is :-j2sdk1.4.2_04
My Java Enviorment is:- Version 1.5.0 (build 1.5.0_04-b05)Why are the versions of your JDK and Java runtime environment different? Why are you not using Java 5 to compile and run everything?
Class Path=C:\j2sdk1.4.2_04\lib;C:\j2sdkee1.2.1\lib\j2ee.jar;C:\JSDK2.0\libIf this is an environment variable, it should be "classpath", not "Class Path" with a space in between. -
Compiling Servlet problem that uses a 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.Hi,
The problem is it is not finding the Bean. Put it in the classpath.
The simplest way is put the class in /WEB-INF/classes/MyPackage folder. -
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.
-
Compiling servlet with helper class
Hello,
I have to write a very large number of database queries and huge amount of code so I decided to make each helper *.class file for each table.
Now I have a main servlet that should instantiate each of these helper classes and conduct DB operations:
//Servlet code
RescardreservationTable rv = new RescardreservationTable();
rv.insertInfo();
RescardPassengerTable rp = new RescardPassengerTable();
rp.insertInfo();RescardreservationTable.class
//does DB opsMy problem is that when I try to compile servlet, I get
insert_data.java:172: cannot find symbol
symbol : class RescardreservationTable
location: class insert_data
RescardreservationTable rv = new RescardreservationTable();
Could somebody please tell me how I can make servlet locate my java classes that it has to use?
Thanks,
Victor.
Edited by: vic_sk on Dec 9, 2008 9:29 AMOk, looks like it's solved. Just forcing the compiler with -classpath to look for the required class file.
-
Why we need to restart server when we compile servlet (not for jsp)
hi
why we need to restart server/appln when we compile servlet .
same thing is not true for jsp
as jsp converts to servlets then also it need not require restart of server/appln.
DannyDear Friends
I hope you guys are doing something with tomcat , So please help me.
can anyone solve my problem.
I am starting my tomcat using startup and the dos window just closes after opening . I don't know why?
The errors generated are as:
Using CATALINA_BASE: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29
Using CATALINA_HOME: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29
Using CATALINA_TMPDIR: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29\temp
Using JAVA_HOME: C:\jdk1.3.0_02
Catalina.start: java.util.MissingResourceException: Can't find bundle for base name org.apache.coyote.tomcat4.LocalStrings, locale en_US
java.util.MissingResourceException: Can't find bundle for base name org.apache.coyote.tomcat4.LocalStrings, locale en_US
at org.apache.commons.digester.Digester.createSAXException(Digester.java:2540)
at org.apache.commons.digester.Digester.createSAXException(Digester.java:2566)
at org.apache.commons.digester.Digester.startElement(Digester.java:1276)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.commons.digester.Digester.parse(Digester.java:1548)
at org.apache.catalina.startup.Catalina.start(Catalina.java:449)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
at java.lang.reflect.Method.invoke(Native Method)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
Using CATALINA_BASE: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29
Using CATALINA_HOME: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29
Using CATALINA_TMPDIR: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29\temp
Using JAVA_HOME: C:\jdk1.3.0_02
Catalina.start: java.util.MissingResourceException: Can't find bundle for base name org.apache.coyote.tomcat4.LocalStrings, locale en_US
java.util.MissingResourceException: Can't find bundle for base name org.apache.coyote.tomcat4.LocalStrings, locale en_US
at org.apache.commons.digester.Digester.createSAXException(Digester.java:2540)
at org.apache.commons.digester.Digester.createSAXException(Digester.java:2566)
at org.apache.commons.digester.Digester.startElement(Digester.java:1276)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.commons.digester.Digester.parse(Digester.java:1548)
at org.apache.catalina.startup.Catalina.start(Catalina.java:449)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
at java.lang.reflect.Method.invoke(Native Method)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
i need your help desperately.
I hope you will respond soon.
thanks
vishal -
when i try to compile servlet i got error message. it can't be identify servlet classes. why is that?
some books mention about class path to fix that problem. but i can't understand.
can any one explain little bit deep?
* i am using windows xp and tomcat server.
-thanks-hi,
for example your tomcat in c:\tomcat5.0 means
set classpath=c:\tomcat5.0\common\lib\servlet-api.jar
or
set classpath=c:\tomcat4.1\common\lib\servlet.jar
or find servlet.jar or servlet-api.jar (thats depend upon your tomcat version)
give classpath for that jar file
and compile -
Unable to compile servlet files in javac
i am unable to compile servlet *.java files in javac.as far as i can see my path is correct.
Kindly provide a solution as soon as possible.
My jdk1.3 is in my c drive and my tomcat in my d drive.
if you are able to compile kindly let me know your path.
it says symbol not resolved.i think that it is unable to import from javaxAssuming that your jdk is in c drive as c:\jdk1.3 set the path and the classpath like as shown below. Remember that you have to set the classpath for the classes in the javax.servlet and javax.servlet.http packages. I know how to do it for JavaWebServer. JavaWebServer has a jar called servlet.jar that contains all these classes. What you need to do is to put this jar file in your classpath. There will be a similar jar file for Tomcat server also. You need to refer the Tomcat server documentation for that.
The path and the classpath have to be set like this...
d:\>path=%path%;.;c:\jdk1.3\bin;
d:\>set classpath=%classpath%;.;c:\jdk1.3\lib;c:\JavaWebServer2.0\lib\servlet.jar;
assuming tht JWS is installed in c:\JavaWebServer2.0
Also note that there should be no spaces in between while setting the classpath. In your case you have to change the last part of the classpath to customize your requirement.
Hope that will help.
Regards
Jaydeep -
Problem compiling Abstract class
Hi
I have writting an abstract class Sort.java and another class BubbleSort.java. I am having problems compiling BubbleSort.java class.
The following is the error message
BubbleSort.java:8: missing method body, or declare abstract
public int doSorting(int[] array);
^
BubbleSort.java:11: return outside method
return num;
^
The following is the code
public abstract class Sort
public abstract int doSorting(int[] array);
}// End of class
public class BubbleSort extends Sort
private int num = 2;
public int doSorting(int[] array);
num = num + 2;
return num;
} // end of classRemove the semi-colon.
public int doSorting(int[] array); // <------- there -
Not Able to compile Servlet from ?
Hi All,
I am not able to compile Servlet from my package:
1) I Have set the CLASSPATH Variable using below line in System Variables:
C:\CC4\prog\jakarta-tomcat-4.1.30\common\lib\servlet.jar
2) Also Set the CATALINA_HOME with value
C:\CC4\prog\jakarta-tomcat-4.1.30
as per above setting servlet should be compiled but still i m getting error message:
1) C:\CC4\prog\jakarta-tomcat-4.1.30\project\classes\com\example>javac ListenerTest
er.java
ListenerTester.java:17: cannot resolve symbol
symbol : class Dog
location: class com.example.ListenerTester
Dog dog = (Dog) getServletContext().getAttribute("dog");
^
ListenerTester.java:17: cannot resolve symbol
symbol : class Dog
location: class com.example.ListenerTester
Dog dog = (Dog) getServletContext().getAttribute("dog");
^
2 errors
2) Error while compiling other file:
C:\CC4\prog\jakarta-tomcat-4.1.30\project\classes\com\example>javac MyServletCon
textListener.java
MyServletContextListener.java:12: cannot resolve symbol
symbol : class Dog
location: class com.example.MyServletContextListener
Dog d = new Dog(dogBreed);
^
MyServletContextListener.java:12: cannot resolve symbol
symbol : class Dog
location: class com.example.MyServletContextListener
Dog d = new Dog(dogBreed);
^
2 errors
So what could be the posible solution here :
do reply !!!
please
Thanks
prabhatI have added servlet.jar in the classpath. But the program is not compiling.The error message says that it can not find classes like ServletConfig, ServletException, Cookie etc. Please help.
-
Problems compiling Zaptel package [SOLVED-ISH]
Hey guys, I'm on an Arch64 system and I'm having problems compiling Zaptel (a dependancy for Asterisk).
Here's the pastebin of the errors I get from the Zaptel makefile: http://pastebin.com/776475
Here's my analysis so far:
There's a line in the Makefile for the zaptel driver that goes like this:
make -C /lib/modules/2.6.17-ARCH/build/ SUBDIRS=/home/woogie/zaptel/src/zaptel-1.2.8 modules
This line activates the kernel's makefile in order to build modules, but specifies that the source directory for zaptel should be included in the make process.
Then things go down the proverbial drain - linux/err_kernel_only.h gets included in the build process, which is designed to do one thing only - stop the build process. So I'm not entirely too sure what's going on here. Is there something misconfigured on my system, or is the Zaptel build system flawed somehow, such that I need to compensate for it?Further information:
I've manually run the problematic make command from /lib/modules/2.6.17-ARCH/build on my own. After reading the kernel makefile documentation, I've learned of the V=1 flag to show me exactly what's going on. The failing command is this one:
gcc -Wp,-MD,/home/cestus/zaptel/src/zaptel-1.2.8/.zaptel.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-unknown-linux-gnu/4.1.1/include -D__
KERNEL__ -Iinclude -include include/linux/autoconf.h -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -O2
-fomit-frame-pointer -m64 -mno-red-zone -mcmodel=kernel -pipe -fno-reorder-blocks -Wno-sign-compare -fno-asynchronous-unwind-tables -fun
it-at-a-time -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Wdeclaration-after-statement -Wno-pointer-sign -I. -Iinclude -O4 -g -Wall -DBUILDING_T
ONEZONE -m64 -DSTANDALONE_ZAPATA -DZAPTEL_CONFIG="/etc/zaptel.conf" -DHOTPLUG_FIRMWARE -I/home/cestus/zaptel/src/zaptel-1.2.8//include
-I/home/cestus/zaptel/src/zaptel-1.2.8//include/oct6100api -DMODULE -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(zaptel)" -D"KBUIL
D_MODNAME=KBUILD_STR(zaptel)" -c -o /home/cestus/zaptel/src/zaptel-1.2.8/zaptel.o /home/cestus/zaptel/src/zaptel-1.2.8/zaptel.c
I've figured out that the bit which causes the failure is "-include include/linux/autoconf.h", because autoconf.h just includes the "err_kernel_only" header automatically, which then slays the build process. And I've also discovered that the Zaptel devs are uber-leet. They've found the magical -O4 level in gcc. You know, the one above 3, where the supported optimization levels in gcc are -O, -Os, -O2 and -O3 -
i'm new to java, just went through the tutorial just now..
tried compilling my program the first time on XP, but the system doesn't recognise the command JAVAC,
i've installed the java compiler (j2re-1_4_1_01-windows-i586.exe)
but it still isn't working.. any help?
thanks!then again.. i'm still having problems compiling..
i managed to install the right sdk, but.. i have to run the command javac from the bin directory.. else the command prompt won't recognise it..
anyway to get around this?
also.. because of this.. i can't compile my program.. :( -
Getting error in compiling servlet
I am trying to compile servlet and I am getting error "cannot resolve symble : class HttpServlet"
there are 6 error almost same not resolve servlet or http. I already add jdk1.3.1 and tomcat in my path I don't understand why I am getting this error please help me.You need to add servlet.jar into the classpath. You can find servlet.jar in tomcat_home\lib dir.
Maybe you are looking for
-
I am setting up my Ipod Touch 32gb. This is replacing another one. When I try to sync this one, I am getting the error message that it won't sync because the disk could not be read from or written to. Does anyone know what this means?
-
My dad deleted quicktime!
hey my dad deleted quicktime and now my itunes wont open and it says,"itunes required files are missing". also my dad tried the system restore and that didnt work either. i tried deleting itune and reinstalling it but still wont open. i dont know wha
-
That little cord that hooks up to an adapter (I can still find that) so I can recharge my Ipod Mini and also allows me to transfer tunes from my computer to my Ipod Mini is lost somewhere in my 3 BR, 2 and 1/2 bath house. I thought, Jesus, I can just
-
How can I use the defaults command to edit a sub key in an array of plist?
For example, how could I edit the Name key in the array? <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Test</key> <array
-
How to use total elements in a script logic?
Hi All, I am using BPC 7.0 MS. I need to create a calculation using script logic as follows: The application name is GYP and it is composed by the following dimensions: PL (Account type) in this dimension are the units Time Category Entity Product Rp