Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Servlets: How do you get started?

Started by Tac-Tics Mar 6, 2002 at 5:05 PM 13 replies 1.8k views
Original Post
Tac-Tics
Tac-Tics
I picked up a book the other day on Java Servlets, but I''m having difficulty figuring out how to download and install them. I''ve fiddled with the maze of files and directories at http://jakarta.apache.org/ but to no avail. Can anyone give me clear instructions on how to set up the Servlet software? Note, I''m using Windows ME. "I''''m not evil... I just use the power of good in evil ways."
WayfarerX
WayfarerX
Sun has a free product called the Java Servlet Development Kit that comes with a little servlet engine. I wouldn''t use it in a production environment, but for simple development it works fine. A lot easier to set up than Apache + Jserv, Tomcat, etc. Take a look at this, specificly the "Running Servlets" link.



"There is no reason good should not triumph at least as often as evil. The triumph of anything is a matter of organization. If there are such things as angels, I hope that they''re organized along the lines of the mafia." -Kurt Vonnegut
"There is no reason good should not triumph at least as often as evil. The triumph of anything is a matter of organization. If there are such things as angels, I hope that they're organized along the lines of the mafia." -Kurt Vonnegut
Tac-Tics
Tac-Tics
I got it to work......

up until the part:


the following command starts the server on Windows:

C:\jsdk\> startserver



When I execute that program, it pops up another DOS window for a split second and then displays:

Out of environment space
Using classpath: ;lib\tools.jar;.;jsdk\lib\servlet.jar;jsdk\lib\jspengine.jar

What does that mean???

"I''''m not evil... I just use the power of good in evil ways."
WayfarerX
WayfarerX
Try this.
"There is no reason good should not triumph at least as often as evil. The triumph of anything is a matter of organization. If there are such things as angels, I hope that they're organized along the lines of the mafia." -Kurt Vonnegut
WayfarerX
WayfarerX
Any luck?
"There is no reason good should not triumph at least as often as evil. The triumph of anything is a matter of organization. If there are such things as angels, I hope that they're organized along the lines of the mafia." -Kurt Vonnegut
Tac-Tics
Tac-Tics
I played around with it a little, but I didn''t quite get it to work. I think I need to learn a little more about Servers in general =-) Thanks for your help though, I''ll try to get it to work again another day.

"I''''m not evil... I just use the power of good in evil ways."
krumms
krumms
Hey,

I had similar troubles a few months back and wrote myself a tutorial when I finished. It''s not up on the web, but if you (or anybody else for that matter!) are interested in a copy, feel free to contact me at the_edge2020@hotmail.com. It guides you through setting up Apache/Tomcat and writing a basic servlet. You''ll need to know how to set up Apache though - it''s not as hard as setting up Tomcat by any measure

Tom
refrain_from_stupidity( &me );
Palidine
Palidine
Finally a question i am qualified to answer

anyway, i do Java server side development for a living.

Download the latest version of Jakarta from:
http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.0.3/bin/

you want the file: jakarta-tomcat-4.0.3.exe

once you have that installed your life will be much easier.

what i usually do is make a shortcut of the <jakarta_install_root>/bin/startup.bat file on my desktop b/c you will be using it all the time.

you will need to create the directory:
<jakarta_install_root>/webapps/ROOT/WEB-INF/classes

everything up to /classes already will exist but make the dir classes exist.

once you get there make another post with the url from which you are downloading the servlets, and i'll step through the process with you and tell you what to do to get it running

-me


Edited by - Palidine on March 8, 2002 6:21:39 PM
Palidine
Palidine
once you get past day 1 of using Jakarta, it will be the easiest possible way to develop JSP/Beans/Servlets.

-me
Tac-Tics
Tac-Tics
Well, I installed Tomcat (why don''t they make such easy-to-follow instructions on their webpage?). However, I just did a little test on one of the precompiled examples (by test I mean I tried to compile it) and it says it can''t find any of the javax.serlet package files. From where / how do I install those?

"I''''m not evil... I just use the power of good in evil ways."
mjacobsca
mjacobsca
You need to obtain servlet.jar from Sun if it doesn''t come with your servlet engine. Then you need to add that jar to the classpath of the engine or your system. That should solve the problem.

Michael
Tac-Tics
Tac-Tics
Wow!
From 60 some errors to 0!
Well, now I know how to compile them and (to a small extent) code them. Now how do I stick them to my webpages? Right now the only two servers I have are crappy Geocities (with my long neglected page) and IP address 127.0.0.1 (my crappy computer at home.. Well... it''s not that bad of a computer actually).

"I''''m not evil... I just use the power of good in evil ways."
Tac-Tics
Tac-Tics
Now that I''ve gotten some servlets to compile, how do I associate them with my webpages? I''ve finally decided tonight (spontaneously and at 3 in the morning) that I''m going to continue working (actually, a complete overhaul) on my webpage (which I haven''t touched since summer) and it''d be really nice to spice it up.

"I''''m not evil... I just use the power of good in evil ways."
Elfs1der
Elfs1der
Where do i download the servlet.jar file i cant find it
Neophyte
Neophyte
In order to associate a servlet with an URL you'll need to modify your web.xml file (probably located in the WEB-INF directory).
Typically add an entry like this:

<servlet>
<servlet-name>MyServlet<servlet-name>
<servlet-class>mypackage.MyServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>myservlet.html</url-pattern>
</servlet-mapping>

Both these tags should be child-tags to the web-app tag which is the root tag of the web.xml file.

You can have multiple servlet-mappings for a servlet, and the url-pattern tag also accepts wildcards.

Hope that helps,
- Neophyte

[edited by - Neophyte on March 11, 2004 8:28:23 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.