Jump to content
  • Advertisement

Archived

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

Horn

[java] Servlets

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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]

Share this post


Link to post
Share on other sites
Ah that did the trick. Thanks Santa. And I use Eclipse to do my java programing which does organize your imports for you. I''ve just never done anything with these blasted servlets yet.

And I''m still at UMaine Farmington as a Junior.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!