java Servelets

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2007
Posts: 36
Reputation: abar_sow is an unknown quantity at this point 
Solved Threads: 0
abar_sow abar_sow is offline Offline
Light Poster

java Servelets

 
0
  #1
Jul 22nd, 2007
how to run servelets in java ..I think there is no error in my following code...In java compiler its tellin that package does not exists.

import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloServelet extends GenericServelet
{
public void service(ServletRequest request,ServletResponse response)throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
pw.println("<b> Hello");
pw.close();
}
}
While compling its showing following errors:

C:\Program Files\Java\jdk1.5.0\bin>javac HelloServelet.java
HelloServelet.java:4: package javax.servlet does not exist
import javax.servlet.*;
^
HelloServelet.java:5: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
HelloServelet.java:7: cannot find symbol
symbol: class GenericServelet
public class HelloServelet extends GenericServelet
^
HelloServelet.java:9: cannot find symbol
symbol : class ServletRequest
location: class HelloServelet
public void service(ServletRequest request,ServletResponse response)throws Ser
vletException, IOException
^
HelloServelet.java:9: cannot find symbol
symbol : class ServletResponse
location: class HelloServelet
public void service(ServletRequest request,ServletResponse response)throws Ser
vletException, IOException
^
HelloServelet.java:9: cannot find symbol
symbol : class ServletException
location: class HelloServelet
public void service(ServletRequest request,ServletResponse response)throws Ser
vletException, IOException
^
6 errors
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: java Servelets

 
0
  #2
Jul 22nd, 2007
You will need to add the required jarfile for the servlet API to your classpath.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 36
Reputation: abar_sow is an unknown quantity at this point 
Solved Threads: 0
abar_sow abar_sow is offline Offline
Light Poster

Re: java Servelets

 
0
  #3
Jul 22nd, 2007
Originally Posted by jwenting View Post
You will need to add the required jarfile for the servlet API to your classpath.
wil u pls explain detaily ...I didnt get u
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,629
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 468
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: java Servelets

 
0
  #4
Jul 22nd, 2007
Have you installed Tomcat? If yes, then the IDE which you must be using would have an option for setting the class path for you.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 36
Reputation: abar_sow is an unknown quantity at this point 
Solved Threads: 0
abar_sow abar_sow is offline Offline
Light Poster

Re: java Servelets

 
0
  #5
Jul 22nd, 2007
Ya i installed tomcat .Do i hav 2 create any xml file for tat servlet program..In book its said tat after compiling in java, its corresponding class file should be pasted in root directory of tomcat.. But its not compiling...???
Attached Thumbnails
baby.jpg  
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,629
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 468
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: java Servelets

 
0
  #6
Jul 22nd, 2007
Yes you have to create web.xml entry for that servlet program and also set the classpath to point to your servlet and jsp jar files.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC