File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error in executing servlet

 
Krishna Bharati
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
mano ranjan
Ranch Hand
Posts: 102
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can you please post your HTMl page so that it will be useful to debug ..

thanks
Mano
 
Rajat Bhatnagar
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13047
6
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic