• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to start servelets

 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
- please let me know how to start servelet programming
- what are the steps neccessary to start working with servelets
- what are the servers necessary to install
- classpath and .bat file mapping
Or other links to get know how about them.
thanks in advance
Rashid
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I Think at first you should go thru servlets doc.you can find tutorials for servlets in www.java.sun.com .after that decide which one you want to use i,e java web server,tomcat,jrun etc..once u decide the server start installing it and if u get any errors r problems post in this site.
-greddy
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ali,
-Use Tomcat software.
-if you are java programmer, you don't need that much to start working with servlet as it is a normal java program (*.java file),not as JSP (which is *.jsp file),you just need to take a look on java.sun.com for servlet short course or documentation . when you edit your file, compile it and then run it from the terminal or call it from a browser(depends on your application), I will provide you with servlet and tomcat links ,I think they are suffecient for you to start working.
just try to run a simple servlet on tomcat and notify us with your comments.
http://webappcabaret.com/javachina/tomcathowto.htm http://java.sun.com/docs/tutorial/servlets/overview/index.html http://java.sun.com/docs/books/tutorial/servlets/call-servlets/index.html
 
Rashid Ali
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have installed tomcat and java web server.
now may i know how can i set up any of them for the purpose of running servlets using above servers.
Is there need of jsdk in addition to the above which i have not yet installed.
Further can i know the configuration setting of any of the above in order to use the same.
Thanks
Rashid
 
Jimi Rock
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rashid,
You don't need to use jsdk .you either use usdk or tomcat , and the latest is widly used now.
I want to ask you if you configure your system according to the link I have previously specified, which is the first one(tomcathowto),if yes ,then you don't need any thing.
just save your servlet files (*.class) in the "classes" subdirectory , you can find it as follows: tomcathome/webapps/examples/web-inf/classes
then try to call your servlet from an html page or using a java program ,it depends.
initially, call it from an html page ,just note that the html pages are found in the following path:
tomcathome/webapps/examples/servlets/htmlfilename.html
If you want to call the .class file , type the following on your browser address bar: http://localhost:8080/examples/servlet/classfilename
**type "servlet" not "servlets" because I had this error when I used tomcat for the first time.
Waiting for your comments,
Jimi.
 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jimi,
Thanks a lot for your help, but your second URL doesn't work, which is http://java.sun.com/docs/tutorial/servlets/overview/index.html
could you have a look ?
Thanks
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Probably this is the URL Jimi menat.
http://java.sun.com/docs/books/tutorial/servlets/index.html
regds
maha anna
 
Jimi Rock
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats it Maha, Thanks
 
Rashid Ali
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank u all very much specially Jimmi for his worth messages and Maha who is one of my favourite sheriffs/bartenders - at last i cought her attention indirectly
Now in addition to the above may I know that is it necessary to have LAN card installed in your PC in order to run servlet/jsp as i read in a link '.../tomcathowto'. Actually i want to run servlet on my home PC in which no lan card is installed.
Can I be advised please.
~Rashid
[This message has been edited by Rashid Ali (edited April 23, 2001).]
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rashid,
No need for LAN card. Tomcat has simple web server + servlet/jsp container. It can server html/jsp/servlets. By default it uses commn port 8080 in your local machine. After installation just http://localhost:8080/index.html will bring us the 'welcome page' of Tomcat, served from Tomcat web server.

From your post, I think you have already installed Tomcat in your machine. If not, for install instructions please make a search in this forum.
regds
maha anna
[This message has been edited by maha anna (edited April 23, 2001).]
 
Rashid Ali
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Maha I shall try.
~Rashid
 
nan sh
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to Jimi and Maha, I finally installed Tomcat and Apache and I can see the "welcom page" of Tomcat.
It is NOT easy to install them, but I've got there.
How can I run these example in "welcome page" of Tomcat myself? how can I tpye in those codes ,compile and run myself?
And may I asked what is different between Servlet and JSP.
 
Rashid Ali
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I only installed tomcat and I did also the same but not succeed
The error is something like that 'the connection to server is not available.'
Even though i have edited the server.xml file as per the instruction but it doesn't serve the purpose.
Please advise.
[This message has been edited by Rashid Ali (edited April 25, 2001).]
 
Rashid Ali
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear nan sh
The following link provided as by Maha and Jimmi shall serve your purpose. Go through throughly and have a nice journey to the servlets and jsp's road
http://java.sun.com/docs/books/tutorial/servlets/index.html
~Rashid
 
nan sh
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rashid
Nan
 
Jimi Rock
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nan , Rashid , pleased because you have successfully run your first servlet.
Regarding the difference between jsp and servlet,may be you need to know that they are almost the same technologies. in simple applications,jsp is used alone in order to handle requests and responses . but in complex applications,servlet could handle requests, and jsp is used to handle responses (suggested senario).generally, jsp is widely used by page designers, but servlet is used by developers.
for more information: http://developer.java.sun.com/developer/onlineTraining/JSPIntro/contents.html http://java.sun.com/j2ee/blueprints/
Nan, if you want to edit your own servlet,do it as any java program. in order to compile it , you need to add the following to your classpath : tomcat_home\lib\servlet.jar .
then run it as usual , note that you need to locate your *.class file under tomcat_home/webapps/examples/web-inf/classes, but when you call your class from the browser , type the following on your browser title bar: http://localhost:8080/examples/servlet/yourclassname
Thanks.
 
Rashid Ali
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Jimmi, i could not be able to run my tomcat as yet.
due to the error that 'the connection to server is not available.' Even though i have edited the server.xml and tomcat.bat files as per the instructions but it doesn't serve the purpose.
Please help - a request to anybody.
Thanks
Rashid
 
Jimi Rock
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not Rashid? This error means that your system does not recognize the tomcat server.
I advise you to delete every thing , then do "exactly" the following:
--download the zip file that contains the latest version of tomcat.
--extract the file to a directory called "tomcat" on your c drive.
--now you notice that your "tomcat" directory contains another directory "folder" , open it and copy all. back to tomcat directory, paste all, deleted the folder that is contained in tomcat directory.
--now you have the following path C:\tomcat\
--prepare you environment variables as specified in the link that I have posted earlier "tomcathowto" .
--go to your command prompt and cd tomcat,cd bin,tomcat start.
--if it does not started , and the same error appears, then may be you are under WINDOWS 98 , then do the following:
***right click on your command prompt title bar, choose properties,choose "memory" tab, set your memory to "4096" or higher. click "ok" , close your prompt,and start it again.
you should be able now to cd tomcat,cd bin,tomcat start.
notify if it works or not...
WISHES,
Jimi.
 
Rashid Ali
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks very much Jimmi for your great support and wishes u extended to me.
I am using Windows 98 and may be the memory error is there. I shall try today evening your suggestion and will let you know by tomorrow the further progress.
thanks again.
Best regards
Rashid
[This message has been edited by Rashid Ali (edited April 27, 2001).]
 
Jimi Rock
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Waiting
 
nan sh
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"in order to compile it , you need to add the following to your classpath : tomcat_home\lib\servlet.jar ."
Why should I put servlet.jar over there for compiling? Why tomcat have relation with compile javac? Is it mean I have to run tomcat before compiling?
(by the way, I put servlet.jar and the others under %JAVA_HOME%/jre/lib/ext)
 
Jimi Rock
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nan , I see that you think that it is a prblem to add servlet.jar to your classpath?
No problem at all , and you don't need to run tomcat before compiling , you just add that jar file because it contains the necessary classes to compile a servlet.
 
Rashid Ali
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Jimi Rock
Actually there was only the problem of memory setting as i told you yesterday under Windows 98 which i resolved and due to which i could not make my all efforts successful. And after setting memory value i could be able to run the tomcat easily.
I really very thankfull to you for your all support you provided to me. Atlast yesterday after going through your yesterday's message throughly i could succeed to run my Tomcat Server for which i am grateful to you and wish you a good health and very successful career in your life. please accept my compliments
My thanks also to the web page author '.../tomcathowto'.
Kind regards
Rashid Ali
[This message has been edited by Rashid Ali (edited April 28, 2001).]
 
Jimi Rock
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rashid, so pleased because you have succeeded running tomcat for the first time.
No need to thank me, we are all friends, today I help you, tomorow you may help me
I will be pleased also to answer any question (if I could),either on javaranch or by email.
Thanks,
Jimi.
 
Rashid Ali
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you too Jimmi The credit really goes to you
~Rashid
 
nan sh
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jimi Rock,
I am able to compile source code now, but I guess I have to spend time to read tomcat document to understand where to put what.
Do you know which book will be suitable for me, I passed SCJP2 and wish go development instead of web design?
Thanks
 
Jimi Rock
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nan, I think that you don't need a book for tomcat.there is tomcat documentation on jakarta site which you have downloaded the software from (as I remember), I am going to tell you the link if you don't find it (because I don't have it now).
Regarding the developer books , they are many, if you are going to use jsp , I advise you with the following book : http://developer.java.sun.com/developer/Books/javaserverpages/
You can search also for servlet books on the sun site .
Thanks,
Jimi.
 
reply
    Bookmark Topic Watch Topic
  • New Topic