• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

error in executing servlet

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am getting the below error when i am trying to run the html which internally calls one servlet.

The requested resource (/Servlets/a.html) is not available.

Can any one please help me.

Thanks,

Krishna Bharati
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can you please post your HTMl page so that it will be useful to debug ..

thanks
Mano
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The requested resource (/Servets/a.html) is not available.

You Might be going wrong because in the form action of your html you have entered some wrong URL.

Ideally the URL should be like
<form method="POST" action="http://localhost:8080/<WEB_APPLICATION_NAME>/SERVLET_NAME>

</form>

Here 8080 is the port on which tomcat is deployed.

Also make sure that you have made the correct entries in your web.xml file for the corresponding SERVLET_NAME. There are some tags like <servlet-name>,<servlet-class> and <url-pattern> for which you need to enter some data corrresponding to your servlet.

Good Luck
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rajat Bhatnagar:


Ideally the URL should be like
<form method="POST" action="http://localhost:8080/<WEB_APPLICATION_NAME>/SERVLET_NAME>



Not true.
Fully qualified URLs are brittle and hard to maintain.
Ideally all URLs will be relative to the contextPath.

See:
http://faq.javaranch.com/java/ResourceUrlProblems
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

run the html which internally calls one servlet.




How does html - the static page description language - call a servlet?
If you mean it has links to servlet resources, that error indicates that the html is never loaded so whever servlet is never called.
Your use of "Servlet" in the URL suggests you may be relying on the dreaded Invoker servlet syntax. Not a good idea.
Bill
[ June 04, 2008: Message edited by: William Brogden ]
 
Rajat Bhatnagar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi BEN

i have a slight confusion here.

Whatever you are saying is right but according to me we can play around with relative paths only to a certain degree.

If we have to deploy a servlet then offcourse we can hide the path from the end user by changing its <url-pattern> tag in deployment descriptor.

But the base of the URL ie http://localhost:8080/<WEB-APPLICATION-NAME> has to be fixed..

I don't think this can be changed as this this is the root path of our Servlet Container (Tomcat) + web application..

Also i wanted to know that if i have a Jsp say x.jsp in webapps/Test-Application-Directory and i want to access via a html page..

Then if have to explicitly mention http://localhost:8080/Test-Application/x.jsp..

Is there any by which we can hide this from the end User. i.e HARDCoded path in HTML page FORM ACTION...

Thanks in Advance
 
Sheriff
Posts: 67750
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 Ben is correctly saying is that the prefix http://localhost:8080 is superfluous and error-prone. It should never be used when addressing resources with the same web application.

Of course the context path must be included for client-initiated URLs.
[ June 04, 2008: Message edited by: Bear Bibeault ]
 
Been there. Done that. Went back for more. But this time, I took this tiny ad with me:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic