• 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
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

first program error, something is missing

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 .
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes my friend i check that there is a class file in same directory please help me guys
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats real pain to answer this kind of question... but not for us.... So happy to help you....
 
kuldeepSingh rathore
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you include the /?
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
kuldeepSingh rathore
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream

Where did you put the Apache Commons I/O jar file?
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does Struts have to do with a class not found exception?
 
kuldeepSingh rathore
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using Tomcat, make sure your web application(WAR or folder) is placed inside 'webapps' folder of Tomcat.
 
kuldeepSingh rathore
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes i fix that now i am able to go through link


but when i press submit
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about my second question?
 
kuldeepSingh rathore
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i didn't get you ? you asking about url write yes i am able to go through url
 
kuldeepSingh rathore
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kuldeepsingh,

I am facing the same problem. can you hepl me please?
 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
kuldeepSingh rathore
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for reply Amit Ghorpade
i try your suggention but got same problem

but relly thanks for reply
 
Amit Ghorpade
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Are we home yet? Wait, did we forget the tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic