It's not a secret anymore!*
The moose likes Servlets and the fly likes BASIC SERVLET HELP.....PLEASE!!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "BASIC SERVLET HELP.....PLEASE!!!!" Watch "BASIC SERVLET HELP.....PLEASE!!!!" New topic
Author

BASIC SERVLET HELP.....PLEASE!!!!

Steve Jensen
Ranch Hand

Joined: Sep 23, 2002
Posts: 126
I want to run the simplest of all servlets on my machine, that is, the HelloWorld Servlet.
Thing is, I have consulted so many different textbooks, trying to find out WHERE I can download all the things necessary to run a servlet on my local machine - but to no avail.
I was told that at the URL http://java.sun.com/products/servlet/industry.html I would be able to download the JavaServer Web Development Kit. So, I went to this page - but I couldn't find it. I then clicked on the Apache Tomcat link. Ok, I was taken top this page, but NOWHERE could I find a link to DOWNLOAD what I needed. I don't want the documentation, or the source code. I want what ever it is I need to run a servlet!!!
Help me, please, somebody!
Bacially, what do i need to download, where can I download it from, and what do i do with it??
I already have JRun 3.1 installed on my machine, if that helps.But when i compike a srevlet, I get errors such as:-
"HelloWorld.java": Error #: 704 : cannot access directory javax\servlet at line 2, column 1.


John Bonham was stronger, but Keith Moon was faster.
balu
Greenhorn

Joined: Feb 21, 2003
Posts: 4
hey go to onjava.com....u follow the instructions to download tomcat apache server..u need that in addition to jdk...
Steve Jensen
Ranch Hand

Joined: Sep 23, 2002
Posts: 126
OK, but where on www.onjava.com do I go??
The servlet link, when clicked on, looks a complete nightmare!
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

oi.

You have a couple old books I think. JavaServer Web Development Kit (JSWDK) is very OLD.

You are also not the only person to be fooled by jakarta's download page. If you go to jakarta.apache.org/tomcat and click the binaries download link, you are taken to another page.

Then on the left you see "Tomcat" and you click it again. You are only taken back to where you started. The binaries download page is for ALL jakarta projects, so just scroll down the page until you see...

Tomcat 4.1.18

There are actually 4 tomcat's listed here, but choose that one. (the page I'm referring to is this one )

That, and a JDK ( *not* just a JRE ) are all you need to use Tomcat.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Further:

If you use windows, you are blessed. There is a windows exe installer that does everything for you. It places shortcuts to stop and start the tomcat server in your start menu.

For my own taste, I like to put tomcat in a path that doesn't contain spaces... so I don't let it install to the default of "C:\Program Files\Apache Tomcat 4.0"

I would put it in c:\tomcat4118

The other thing the installer may or may not do (I can't tell because I installed mine some time ago, and forget if I put them there, or the installer did) is place two variables in your system.

CATALINA_HOME should be set to c:\tomcat4118
JAVA_HOME should be set to c:\jdk131 (or wherever you have your JDK at)

As for *compiling* your servlets, Tomcat includes the jar file you need. CATALINA_HOME\common\lib\servlet.jar should be placed into your classpath when you compile.

Check out our Apache/Tomcat forum for lots of posts with setting up Tomcat as a subject.
[ February 21, 2003: Message edited by: Mike Curwen ]
Steve Jensen
Ranch Hand

Joined: Sep 23, 2002
Posts: 126
Right, so this is the actual download i need? :-
tomcat-4.1.18-LE-jdk14.exe
http://www.rge.com/pub/infosystems/apache/jakarta/tomcat-4/binaries/tomcat-4.1.18-LE-jdk14.exe
I'm got a PC running Winows 98 s.e.
Steve Jensen
Ranch Hand

Joined: Sep 23, 2002
Posts: 126
OK
I've installed it
So, now how do i use it?
I'm using JBuilder 6, if that's of any help.
Another thing, when i start Tomcat, I don't see an icon for it in my windows task bar - is that to be expected??
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

well, windows 98 is a bit different. The startup scripts for Tomcat will not work that well.

Also, if you're using a version of JBuilder6 above the free one (I can't keep up with what they call it these days)... tomcat is built-in to the IDE.

For configuring Tomcat, I'd suggest the Apache/Tomcat forum. You'll find posts like this one That's about WinME, but the same will apply for Win98.

Search that forum for Win98 -> there's more issues.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

The other link that seems quite popular is this one...

http://www.moreservlets.com/Using-Tomcat-4.html

My own personal opinion is that steps 2,3 and 4 are not entirely needed (in particular step 3). Having said that, if you follow through this page, you need to do all the steps for his examples to work.
Mehdi Chaouchi
Greenhorn

Joined: Jan 31, 2003
Posts: 14
Hello every1,
Do I really need to download TomCat to try out servlets... I don't think so, not according to sun.java! or am I missinf something.
According to sun tutorials you only need to:
1- download regular Java, j2se
2- jsdk2 (java servlet dev kit)
3- set your PATH variable to include "..jsdk2\bin"
4- Copy ..\jsdk2\lib\jsdk.jar where CLASSPATH can access it.
5- run ..\jsdk2\bin\servletrunner.exe
Here you might check that now the port 8080 is listned to!
6- compile the example that you could download from java.sun namely: HellowWorldServlet.java that should be put on the example directory.
7- Open your browser to http://localhost:8088/servlet/HelloWorldServlet
And it should work.... well it should but 4 me it doesn't !!! I have no idea why??
Do I need to download a server (TomCat)... I can't see why. If I got it right servletrunner.exe does al there is to do!!!
Any hints???
Thanks in advance!!
One more afternoon like this with Java and I divorce it! ... I prefer C++ & make files on UNIX.. at least it's has some logic to it!!!
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
Too me loading and running Tomcat was very simple. I have loaded on W95 without much effort. By the way I have never loaded it on W98. But I can't imagine it being that much different. Basically you pull the windows version from the jakarta website, load it,
edit your autoexec.bat file by inserting a CATALINA_HOME="tomcat directory" and the JAVA_HOME="J2KD direcotory". Reboot your machine to make the environment variables global. Then open up a MS-DOS window, "cd" to the %catalina_home%\bin directory and at the command prompt run starup.bat. You should see a seperate MS-DOS window open and display the server starting up. By the way there is also shutdown.bat file to obviously shutdown the server. There are also Unix versions of these bat files located int the \bin directory. And your off and running.
craig
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Mehdi,

That is *old* technology. Get a newer tutorial and Tomcat is now the reference implementation of a servlet container. servlet.exe used to be it. Now it's Tomcat. And this *is* according to sun.

http://java.sun.com/products/servlet/index.html has a Tomcat icon on it.
Mehdi Chaouchi
Greenhorn

Joined: Jan 31, 2003
Posts: 14
Thanks Mike,
I did install Tomcat with little difficulty though.. for some reason my machine (Windows XP) won't use CLASSPATH that I specified as a environement variable,.. each time I wanna compile I have to use the -cp option! .. anyways.. at least the examples are working. Now I have to sit down ans learn Servlets+JSP. Woul�d you have any idea on how much time it could take. For instance 1 month (3 hours per day 5 days a week).
Thank you for any input.
Cheers. Mehdi.
Ivan Tamayo
Ranch Hand

Joined: Aug 13, 2001
Posts: 49
Hi Mehdi,
I use Textpad + Tomcat for servlet development. You can just put the servlet.jar file in this directory:
%JAVA_HOME%\jre\lib\ext
in this way, the java compiler is able to find the servlet package without the classpath option
Mehdi Chaouchi
Greenhorn

Joined: Jan 31, 2003
Posts: 14
Hi Ivan,
I tried to do that but it didn't work.. I know it's strange...!!
Anyways, it's ain't so important! the main thing that worries me is how much time should I give this Servlet thing and whether it's worth it.
I always had this problem of not being very good at taking decisions.
Cheers
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I had noticed that Tomcat didn't like running under Win XP home edition on a laptop I bought about 8 months ago.

Perhaps XP Pro is different, and maybe more recent versions of Tomcat will behave better. (I no longer have the laptop, and I use Win2k, so I can't test it out).

I too found it very puzzling why the CATALINA_HOME variable was not picked up.


As for whether or not servlets are "worth it"... I think pursuing knowledge is a worthwhile goal at all times. The more things you teach yourself, the easier new things become. And servlets and j2ee in general is a fairly worthwhile thing to know about. On the other hand, if you make your living coding VB.NET, then maybe it's not something you should spend an awful lot of time on.
Mehdi Chaouchi
Greenhorn

Joined: Jan 31, 2003
Posts: 14
Hi Mike,
Just to let you know that I am using windows XP on a lap top as well!!!
So,.. maybe that\s the problem!!
Thanks for your advice. For the time being I\m jobless.
Cheers
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
I have XP and Tomcat runs fine. Both the windows installer which makes it a service and the zip version. Where you have to set catalina_home. I also don't have a problem setting classpath.
How are you trying to set the classpath?
1. Control Panel
2. System
3. Advanced tab
4. Environment Variables button
5. New (Under system variables)
6. put in the name and path then ok all the way out.
Mehdi Chaouchi
Greenhorn

Joined: Jan 31, 2003
Posts: 14
Hi Paul,
I tried that and it didn't work as expected!
Anyways, it's not that important, it's working now! the only "problem" is that I ave to use the -classpath option anytime i wanna compile!
For the time being I'm just pondering on what to do noext! I'll be finishing Core java in few days (self study). I'm not sure I wanna spend that much time on Servlets. Maybe I should rather study JDBC, or something else, JDOM, DOM2 for XML!
I just don't know what to do and on what to concontrate... What's gonna be more helpful to find a job???
Cheers
Mike Nightsky
Ranch Hand

Joined: Aug 18, 2001
Posts: 48
Originally posted by Mehdi Chaouchi:

I'm not sure I wanna spend that much time on Servlets. Maybe I should rather study JDBC, or something else, JDOM, DOM2 for XML!
I just don't know what to do and on what to concontrate... What's gonna be more helpful to find a job???
Cheers

Hi Mehdi!
Im a java programmer and did servlet programming for more than 2 years now , it is quite usefull.
You could look at JSP for me this is the future of servlets. JDBC is a "basic" its good to know, but most projects have a framework or generator that creates the DBconnections.
XML is also very interesting, because its a generic way for data interchange. XSL and XSLT is a little tricky , and you only should worry about it if you have to generate documents (doc,pdf,pure html).
I used almost any java api which exists (except J3D) for my projects. So there is much you can study and every time you close a chapter your one step closer to the "guru" status.
The most helpful to find a job is searching.
But if you have a SCJP Certification (Sun Certified Java Programmer) your chances of being considered are much better than without.
[ March 05, 2003: Message edited by: Mike Nightsky ]

Win the opportunity to make money on the Internet<br /><a href="http://sweeps.sitesell.com/minirich.html" target="_blank" rel="nofollow">http://sweeps.sitesell.com/minirich.html</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BASIC SERVLET HELP.....PLEASE!!!!
 
Similar Threads
SCWCD Forum FAQ's....................
Google web services
Executing the App on CLDC
Java Plug in for SWING applet
install probs in Jboss 4.0.5