• Popular Now

• 13
• 18
• 19
• 27
• 10

Archived

This topic is now archived and is closed to further replies.

[java] Servlets

This topic is 5135 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

This really isn''t related to game dev but I don''t know where to ask. I''m trying to compile a servlet but I ran into a wall. I don''t seem to have the javax.servlet.* classes. I got the java 2 ee sdk (the large 120 meg one), tomcat (the precomiled samples work), and the jwsdp. As far I as I can I have the latest versions of everything. Could someone point me in the right direction? Heres the source to the sample program.

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("H ello World");
}
}


Share on other sites
Holy crap, it''s Horn. SantaClaws from the Quake community. It''s been a while since I''ve done anything servlet related, but maybe I can help. I had this same problem when I first started using servlets, and it was because I didn''t have the JAR file it needed (servlets.jar I think?) in my CLASSPATH. How are you compiling it?

Share on other sites
Yes its me. Strange finding you here.

I''m just compiling it using the command line (javac HelloWorld.java). I searched my comp for servlets.jar but it comes up with nothing but there are a few servlet-(something).jar. I''m kinda new to this java thing so how would I reference these files (assuming they''re the ones I need).

Thanks for the help.

Share on other sites
Hi,
er ... I can''t say I''ve had much experience with servlet''s but I suggest you get an IDE fast. I''m sure there''s a free one somewhere. THat''s the key to automation - let the IDE reference the files for you

Share on other sites
I downloaded the latest packages to check it out and it does indeed have classpath problems in the default installation. Quick solution:

C:\>javac -classpath \path-to-jwsdp\common\lib\servlet-api.jar HelloWorld.java

You can add an environment variable under your system properties called CLASSPATH and give it the same value and it should fix it permanently.

In reference to IDE's, I've always liked JCreator. Lightweight, and does the job.

Are you still at university?

[edited by - SantaClaws on February 26, 2004 12:00:48 AM]