wood burning stoves 2.0*
The moose likes Servlets and the fly likes first program error, something is missing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "first program error, something is missing" Watch "first program error, something is missing" New topic
Author

first program error, something is missing

kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
Hi friends i newly brought head first j2ee book and try to learn from that but when i run my first html page it's not able to find "select.do" in web.xml

error:
You tried to access the address file://localhost/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%205.5/webapps/beer-v1/com.example.web.BeerSelect.java, which is currently unavailable. Please make sure that the Web address (URL) is correctly spelled and punctuated, then try reloading the page.

Files:
\Tomcat 5.5\webapps\beer-v1\form.html


\Tomcat 5.5\webapps\beer-v1\web-infweb.xml


\Tomcat 5.5\webapps\beer-v1\web-inf\classes\com\example\web\BeerSelect.java
package com.example.web;

please friends help me i am waiting for your reply



[ July 20, 2008: Message edited by: Bear Bibeault ]

[ July 20, 2008: Message edited by: kuldeepSingh rathore ]

[ July 21, 2008: Message edited by: kuldeepSingh rathore ]

[ July 21, 2008: Message edited by: Bear Bibeault ]
[ August 18, 2008: Message edited by: kuldeepSingh rathore ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along. Please read this for more information.

You can go back and change your post to add code tags by clicking the .


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
shar ball
Greenhorn

Joined: Jul 14, 2005
Posts: 6
Hi kuldeepSingh,

Can you tell what is the URL you are using to access your application?
You can go though the Servlets video tutorials here - www.sharmanj.com.
I have added some demo with source code as well.

Thanks,
Sharad.
kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
hey Bear Bibeault i am sorry i don't know the rules but i cahnge as you said and now its very easy to understand thanks.

hi sharad thanks for reply
i am using tomcat and i am gone to this url:web page and when i am pressing submit buuton i got this error please help me friends
Robert Miller
Ranch Hand

Joined: Jun 18, 2004
Posts: 56
It doesn't look like there is a problem finding select.do, since according to the error message you posted it knew to look for BeerSelect. I'm concerned that the message mentions BeerSelect.java, since the web container shouldn't need or even know about the source file.

Have you verified that the class file is correctly installed? It has to be in .../beer-v1/WEB-INF/classes/com/example/web/BeerSelect.class.
kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
yes my friend i check that there is a class file in same directory please help me guys
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

The error message is very perplexing, because the run-time environment has no need of .java files.

But, your form action:
<form method ="post"
action="SelectBeer">
does not match your servlet mapping of /SelectBeer.do.
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Thats real pain to answer this kind of question... but not for us.... So happy to help you....


Never try to be a hard-worker. Be a smart-worker.
My Blog
kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
hey Bear Bibeault thanks buddy i checked that in book it so i changed it but steel i got the same error,please friends help me
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

Did you include the /?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

Oh, and by the way, please be sure to take the time to compose descriptive subjects for your posts; read this for more information.

You can go back and change your post to add a more meaningful subject by clicking the .
kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
yes Bear Bibeault sir i am included that / but still got the error,and i will change post name
Please friends help me i stuck to this third chapter from last sunday please friend help me
kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
one thing is more i have to add that when i am enter url as mention in book that is http://localhost:8080/Beer-v1/form.htmli got error:
so i open form page manually go to open and then open that form page and when i sumbit button i got the first post error
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

If you can;/t access anything in the web app, it's likely that the problem is in the app setup and not this particular servlet.
kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
hi shrad your tutorial is very good but i got stuck .
when i am try to deploy war file in tomcat manger it show me error

please every one help me i tried of doing this thing every time stuck
one thing more is it compulsory create war file because in head first book there is no mention about war file
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

one thing more is it compulsory create war file because in head first book there is no mention about war file

No its not compulsory, its just a handy archive for deployment.
And as Bear pointed out, check if there is a problem with your setup.
See if you can access the tomcat's index file.
If yes then (although not recommended) try deploying your application in the web app ROOT instead of Beer v-1.


Hope this helps


SCJP, SCWCD.
|Asking Good Questions|
kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
that's fine but still i am getting error when i am try deploy any war file i got same error as above i mention and please friend reply me
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream
Where did you put the Apache Commons I/O jar file?
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2234
    
    7

Are you using struts? If so, from my understanding about Struts, in web.xml you don't need to mention the do part. But in your form include the do part (not using the struts syntax).


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

What does Struts have to do with a class not found exception?
kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
hey friends please don't confuse me i am new to servlets and i don't know struts and all of this thing i just wanted to run my first servlet program and that take more a month to due it first i was trying from book there i got error as i mention above You people said i done some setup problem now i saw all sharad video to learn they where good but he said deploy war file i try that too still i got error that i mention below

Friend i don't know jar i/o directory
but my war file directory is

please any one is there who run his first program
Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
If you are using Tomcat, make sure your web application(WAR or folder) is placed inside 'webapps' folder of Tomcat.


Thanks and Regards
kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
friend i try that i replace my war file to webapp folder but there already my file exits still i replace and got the same error so still fail
please give me proper solution or proper tutorial where i find solution

please!!please!!please!!please!!please!!please!!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

Have you fixed your action value? What happens when you try to hit the action URL directly by typing it into the browser address bar?
kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
yes i fix that now i am able to go through link


but when i press submit
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

What about my second question?
kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
and one more think more now i am able to deploy war file it say ok in tomcat manager and show in the list but stil when i go to link

kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
i didn't get you ? you asking about url write yes i am able to go through url
kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
as NO ONE INTERSTED TO REPLY I JUST TRY TO DO SOMETHING MY SELF
I HOPE THIS WILL HELP U TO REPLY ME

I just replce my web-inf folder and form html file to root directory that is

and then try to go to link

and enter the colour and click submit button it works program run in that folder
so do i have to do it all time
its work in root dir but not in my beer-v1 selcted directory that is
[/CODE]C:\tomcat\webapps\beer-v1[/CODE]
ME i KNOW WHY?

I HOPE THIS WILL HELP YOU TO REPLY

I AM HAPPY ATLEAST MY PROGRAM RUNS AND GIVE ME MY OUTPUT
Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
Could you please tell the following:
1.Directory where your web application is placed.
2.'action' that you have specified in the form on your page
3.URL Pattern of the servlet in web.xml

Maybe this may help in finding the cause of the problem.
Kavitha Sen
Greenhorn

Joined: May 15, 2008
Posts: 28
Kuldeepsingh,

I am facing the same problem. can you hepl me please?
omkar patkar
Ranch Hand

Joined: Aug 25, 2005
Posts: 231
Hi Kuldeep,

Lets see things that you should be doing to get your application in working state!

try out these things:-

1) Write the servlet url mapping in web.xml and it must match with your "SelectBeer" which you have mentioned in the form tag of your html form.

e.g. If you are going to access your servlet directly through url of browser of form submission as "SelectBeer.do" ...then give the servlet url mapping as either "SelectBeer.do" or "*.do"

2) Check the servlet name you have given. I am not sure... but the white space that you have specified in the servlet name can cause problem....try to keep the servlet name as :-

"Ch3Beer".... instead of "Ch3 Beer"

First do this ....and let us know what result do you get ?

Cheers


Thanks and Regards
Omkar Patkar (SCJP 1.4)[url]http://javacollectionsnotes.blogspot.com[/url] | [url]http://omkar-myscjpexp.blogspot.com[/url]
kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
sir Satya Maheshwari i mention everything in my first post still i mention everything again for you
1)web application is in dir:
2)my html file is there in my first post still it submit action in form
3)i new to this thing i don't know what is url pattern but if i guess http type the link is

i think i answer this plenty of time
any thing you wanted to please let me know
kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
omkar patkar
1)sir you can check my file both have same name SelctBeer.do
2)i try ch3beer but got the same problem
thanks for reply
vinal sen
Ranch Hand

Joined: Dec 13, 2007
Posts: 37
Hello kuldeep!

I am also in the same stage as yours! Getting introduced to servlets for the first time.I also got errors like yours.

1.I did not change directory structure.I did it exactly as given in the book.
2.we receive the errors because:
a.we fail to copy the files in the deployment structure
b.we fail to correctly set the classpath,environment variables like catalina and java_home variable
c.in the classpath we forget to include servlet-api.jar

It worked perfectly after I corrected these mistakes.

thanks
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

as NO ONE INTERSTED TO REPLY I JUST TRY TO DO SOMETHING MY SELF

Please show some patience.



its work in root dir but not in my beer-v1 selcted directory that is
[/CODE]C:\tomcat\webapps\beer-v1[/CODE]
ME i KNOW WHY?


The reason is your url pattern in the servlet mapping, it is mapped to the context ROOT directory.
If you change it to <url-pattern>/beer-v1/SelectBeer.do</url-pattern> then it should work from the beer-v1 directory.
Let us know if this solves your problem.

Hope this helps
kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
hi vinal sen,
thanks for reply
a)I think check everything is perfect but still i mention my file in post you can check everything perfect
b)i added enviroment variable JAVA_home and TOMCAT_HOME directory
3)i added servlet file to jre/lib/ext dir
kuldeepSingh rathore
Greenhorn

Joined: Jul 20, 2008
Posts: 22
thanks for reply Amit Ghorpade
i try your suggention but got same problem

but relly thanks for reply
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

You are welcome
with the following URL pattern
<url-pattern>/Beer-v1/SelectBeer.do</url-pattern>

and the request string
http://localhost:8080/Beer-v1/SelectBeer.do
should work for you.
Given that your web.xml is still in the context ROOT directory of Tomcat.
If you put the web.xml in the Beer-v1/WEB-INF directory then you will need
<url-pattern>/SelectBeer.do</url-pattern> this mapping.

I think you are facing problem just because of the directory structure and corresponding mapping. To get a better picture of these take a look at Tomcat deployment also take a glance through first few pages of the deployment chapter in that book.

Hope this helps
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: first program error, something is missing
 
Similar Threads
Servlet code problem....from HFSJ
HTTP Status 404 problem
Headfirst ch3 Beerselect submit button not working
Tomcat 5.5 - application development
Getting problem with post method