aspose file tools*
The moose likes Servlets and the fly likes error in executing servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "error in executing servlet" Watch "error in executing servlet" New topic
Author

error in executing servlet

Krishna Bharati
Greenhorn

Joined: May 12, 2008
Posts: 4
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

Joined: Jul 12, 2007
Posts: 102
Hi,
Can you please post your HTMl page so that it will be useful to debug ..

thanks
Mano
Rajat Bhatnagar
Greenhorn

Joined: Mar 11, 2008
Posts: 22
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


Regards<br />Rajat Bhatnagar<br /><a href="http://guideofgreatness.googlepages.com" target="_blank" rel="nofollow">http://guideofgreatness.googlepages.com</a>
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12805
    
    5
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

Joined: Mar 11, 2008
Posts: 22
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

Joined: Jan 10, 2002
Posts: 61426
    
  67

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: error in executing servlet