• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

my first servlet please help.

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my very first servlet.
I have compiled the servlet at this location:
D:\tomcat\jakarta-tomcat-3.3.1\webapps\myJSPs\jsp\Whitehead\chap11
So thus in the directory there is two files:
ServletOKlogin.java
ServletOKlogin.class
I have then created A WEB-INF folders inside chap11 and then another inside WEB-INF called classes. Inside this folder I have put the file ServletOKlogin.class, here is the path:
D:\tomcat\jakarta-tomcat-3.3.1\webapps\myJSPs\jsp\Whitehead\chap11\web-inf\classes

Below is the very simple servlet

Please not I am using Tomcat webserver
Then in the browser to execute the servlet I enter this URL in the address:
http://127.0.0.1:8080/myJSPs/jsp/Whitehead/chap11/ServletOKlogin
but I get an error:
HTTP 404 - File not found
Internet Explorer

Do I need to do anything else??
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Northfield Sid,
I did the following to test your servlet, ServletOKlogin.
(1) I have a Web Application named test; my directory structure as follows:
webapps
|
|---test
|
|---WEB-INF
|
|---classes
(2) I compiled your ServletOKlogin.class under WEB-INF/classes directory.
(3) Started the TOMCAT Server.
(4) In the browser address bar, I typed http://localhost:8080/test/servlet/ServletOKlogin
It worked fine.
Good Luck
Thambi
 
Thambi Rajah
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, the directory structure diagram (in my previous reply)did not show up as I typed.
The location ServletOKlogin.class is webapps/test/WEB-INF/classes.
Hope it helps.
Thambi
 
northfield Sid
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay Here is my paths:
WEB-INF\classes
Inside this folder there is one class called
ServletOKlogin.class

I have the other path
d:\tomcat\jakarta-tomcat-3.3.1\webapps\test\servlet\

In here I have two classes
ServletOKlogin.java
ServletOKlogin.class
I am accessing the servlet via the browser:
http://localhost:8080/test/servlet/ServletOKlogin
I still get the same error "HTTP 404"
Please note I am using tomcat 3.3.1
What version are you using?
I don't think it should it matter?
 
northfield Sid
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry forget the path:
Okay Here is my paths:
d:\tomcat\jakarta-tomcat-3.3.1\webapps\test\WEB-INF\classes
Inside this folder there is one class called
ServletOKlogin.class

I have the other path
d:\tomcat\jakarta-tomcat-3.3.1\webapps\test\servlet\

In here I have two classes
ServletOKlogin.java
ServletOKlogin.class
I am accessing the servlet via the browser:
http://localhost:8080/test/servlet/ServletOKlogin
I still get the same error "HTTP 404"
Please note I am using tomcat 3.3.1
What version are you using?
I don't think it should it matter?
 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried also, it works fine.
delete your second path :
--> d:\tomcat\jakarta-tomcat-3.3.1\webapps\test\servlet\
and keep only d:\tomcat\jakarta-tomcat-3.3.1\webapps\test\WEB-INF\classes . Put in 'classes ' folder tour servlet ServletOKlogin.class
- restart Tomcat
- write as URL http://localhost:8080/test/servlet/ServletOKlogin
it must work.
 
northfield Sid
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>http://localhost:8080/test/servlet/ServletOKlogin
Okay so it works.
But I am a little foxed.
I have no folder called servlet inside test?
 
Engin Okucu
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
than i'm sorry. by writing d:\tomcat\jakarta-tomcat-3.3.1\webapps\test\servlet\
I tought you had a folder called servlet.
 
northfield Sid
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>than i'm sorry. by writing d:\tomcat\jakarta-tomcat-3.3.1\webapps\test\servlet\
I tought you had a folder called servlet.
Now I am totally perplexed.
At present I have one path:
d:\tomcat\jakarta-tomcat-3.3.1\webapps\test\WEB-INF\classes
inside the classes folder is one clases:
ServletOKlogin.class
I access the servlet by
http://localhost:8080/test/servlet/ServeletOKlogin
I am 100% sure I have no folder called "servlet" but it "WORKS" ???
Why???
 
Engin Okucu
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now i understand you hmmmm...
you don't have to put a folder called 'servlet' because your server(Tomcat) knows that you are calling a servlet by writing '/servlet/ServeletOKlogin'
the is a mapping to WEB/classes that corresponds to 'servlet'. The container do it for you...
 
northfield Sid
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to access the ServletOklogin from an html page.
But unable to do this.
I am not sure what the path should be:
The ServletOklogin.class is located at this path:
D:\tomcat\jakarta-tomcat-3.3.1\webapps\test\WEB-INF\classes
I have the testServlet.html under the test folder, so thus the path is:
D:\tomcat\jakarta-tomcat-3.3.1\webapps\test

What should the path be for the "action" variable in the form??
I have tried other variations like:
"test/WEB-INF/classes/ServletOKlogin"
etc.
but get the error:
HTTP 404 page cannot be found???
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey
i have wrote a html page which referred to a servlet.
the action tag look like this:
<form action="http://localhost:8080/examples/servlet/Coffees4" method="get" />
it work`s.
maybe your tomcatserver is not running?
bernd
 
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic