how to solve error http status 404 in servlet jsp [duplicate] - java

This question already has answers here:
Servlet returns "HTTP Status 404 The requested resource (/servlet) is not available"
(19 answers)
Closed 6 years ago.
I am trying to run some basic servlet and jsp program with Tomcat. but it gives some error.
I am using Tomcat 6.0.29 and jdk 1.6.0_21.
When i click on WebAppl link in Tomcat then it gives below error
HTTP Status 404 - /WebAppl/
type Status report
message /WebAppl/
description The requested resource (/WebAppl/) is not available.
I tried another code which was running properly on Tomcat 5.5.9. But still gives same error here.
HTTP Status 404 - /SampleAppl/
type Status report
message /SampleAppl/
description The requested resource (/SampleAppl/) is not available.
What should I do to solve this error?
Is it because of new version of Tomcat? Can anyone guide me.

Either you are not using the right URL to access the web application, or you had an error when deploying. Have a look at the Tomcat server logs to see if there is anything in there.
Also the management console might help you getting the URL right.

It looks like your web applications are not deployed. Check carefully the log files of the booting of your tomcat. It will indicate when it starts deploying your webapps and why they failed.
The stacktraces stick out like a sore thumb and following the Up, or looking in down for 'Caused By' lines usually gives a reason why they do not deploy.
If you are stumped you may want to post some parts to this site to ask for guidance.

Your project hierarchy is the one that needs to be checked
project-
src-
servlet
webcontent-
web-inf-
web.xml
index.jsp
Your url will be http://localhost:8080/project

You say you are using tomcat. In that case check the $tomcat/webapps directory. There should be a WebAppl and a SampleAppl directory (and/or war) in there.
Als check the $tomcat/logs directory and read catalina.out (the logfile). Check for Exceptions and the text deployed. You would expect that it says that application WebAppl is deployed.
Of course,you do have to connect to your tomcat. Tomcat is usually listening in port 8080 (check $tomcat/conf/servlet.xml). It could be that you are connecting to another application at port 80 (the http default, usually Apache or IIS).
If it is in port 8080, your URL should look like: http://localhost:8080/WebAppl

Might be
1)Don't violate folder creation structure hierarchy and place corresponding files
2)web applications are not deployed
3)right URL to access the web application
4)Container not yet started(because check out the port numbers that may clash with earlier configured setups )

It could be due to missing tld files in WEB-INF directory which are being used, inside JSP, example JSTL Core.
<c:out value="${salary}"/>

Related

404 error when i call webservice in java

I have created a jersey web-service in Java and I have the following issue:
When I run the project in my localhost apache tomcat server, I call it with the URL localhost:8080/api/verify? and I haven't any problem.
When I upload it in my web-hosting and I call it with URL myDomainName/api/verify? I get 404 error.
Does anyone know why it's happened?
Thank you in advance
Check your web service to be deployed and successfully started (on 80 port).
Check your hosting security settings to allow access to /api/*.
Please try what others have suggested and also check if your domain name (myDomainName) is the correct one. If you have packed your projected as a war check the name of the generated folder.
Check your DNS server, your firewall, and your load balancer to make sure they are pointing to your app.
Verify if you are using http or https.
Edited to add: make sure your default tomcat port 8080 is there in the load balancer (if you have one). If you don't have one yet try http://yourDomainName:8080/api/verify and see if that's all you need.
Thank you all for your responses.
The problem was resolved by my web hosting support.
The solution was the following:
He changed the mappings (mod jk tomcat connector ) from .jsp to / to fix the issue.

Constant warning when running tomcat from intellij

All of a sudden, when i run tomcat from within intellij, the output console is constantly bombarded with messages.
(very) short video showing this:
http://screencast.com/t/ddBhIh3UZiA
The messages constantly output is:
16:05:31,157 WARN http-nio-8222-exec-1 servlet.PageNotFound:198 - Request method 'HEAD' not supported
16:05:31,158 WARN http-nio-8222-exec-2 servlet.PageNotFound:1120 - No mapping found for HTTP request with URI [/] in DispatcherServlet with name 'dispatcher'
I am using Spring 4.1 and tomcat 8.
Java 8 and Windows 8.1
This phenomenon didnt use to happen before and it suddently started occuring. What is going on?
I'm having the exact same problem. If you have your Tomcat run configuration set to open a browser on launch, IntelliJ will try to ping the website to ensure it's up prior to opening the browser. I believe it's doing HEAD requests and since your site isn't set to answer / HEAD requests, you get the error.
Unchecking the "After launch" checkbox under "Open browser" in the server tab of the run configuration fixed it for me.
As for getting JetBrains to fix this, I'm not sure what to do about it. I did just upgrade to 14.0.3 so that might be the cause...
Solved by JetBrains in this ticket, and if you want you can change a Jar to avoid the regression.
https://youtrack.jetbrains.com/issue/IDEA-135196
It seems your client is using HEAD has the request method. It is similar to GET but it says to the server that it must not return message-body in the response.
Either check your pages or client for HEAD requests or accept HEAD as RequestMethod like this:
#RequestMapping(method = {RequestMethod.GET, RequestMethod.HEAD})

Tomcat 5.5: The requested resource is not available [duplicate]

This question already has answers here:
Servlet returns "HTTP Status 404 The requested resource (/servlet) is not available"
(19 answers)
Closed 6 years ago.
I'm having some trouble getting my web app to launch on my server. The URL is:
http://www.apollowebworks.com/kmsales/ItemSearch.do
It used to work fine, and still runs on my local build using Eclipse. I noticed it wasn't working anymore sometime after my hosting provider informed me that they were migrating to a new server.
This is the error I'm getting:
HTTP Status 404 - /kmsales/ItemSearch.do
type Status report
message /kmsales/ItemSearch.do
description The requested resource is not available.
Apache Tomcat/7.0.42
I find it suspicious that it's posting "Apache Tomcat/7.0.42". My host has Tomcat 5.5. I am running it on a 5.5 build locally. I was initially running it on a higher build, and I'm thinking maybe some of my xml files or jars might still reference the wrong Tomcat somehow. I can't find that anywhere though. Any idea where else to look?
The libraries I'm using are:
javacsv.jar
jstl.jar
mysql-connector-java-5.1.15-bin.jar
standard.jar
You said "migrating to a new server". This is most likely why you see there Tomcat 7. I think you need to check with your provider to see what exactly they migrated. Maybe your app wasn't copied to the new Tomcat. In any case you really need to see if your app is there where it should be and, if it is, check the log files.

Error pages in Grails app hosted using IIS 7 / Tomcat connector

I have a Grails application that is running in Tomcat 7 under IIS 7, using the Jakarta Isapi Tomcat connector version 1.2.30 and I'm having trouble getting the error handling to behave how I'd like. The Tomcat connector is configured in uriworkermap.properties to forward all requests below the application's URL to Tomcat:
/OrderSubmission/* = worker1
The Grails application has its own custom error pages which work fine when the application is running on a development machine without IIS / the Tomcat connector, but when on the server, if custom error pages are switched on in IIS, these always override the ones in the Grails application. This means that where I have a specific page to handle a certain exception type, e.g. in UrlMappings.groovy:
"500"(controller: 'error', action: 'itemNotFound', exception: ItemNotFoundException)
...I'm instead seeing the static 500 error page that I've pointed IIS at.
If I instead turn on detailed errors in IIS I get the correct error pages through from my Grails application - however, if a request is made for a URL outside of the application's context, I then see the detailed IIS 404 page, which is unacceptable. If I change the Tomcat connector's uriworkermap.properties to include everything from the root downwards then I instead see a default Tomcat 404 error page. I've tried getting the Tomcat connector to default to custom pages by setting the error_page option in isapi_redirect.properties to point to my IIS static custom pages like so:
error_page=/%d.htm
...but this doesn't work, and I can't find any example of using this setting anywhere.
What I need to happen is for the custom Grails error pages to be shown - unless the URL being requested is outside the application or the application is down, at which point I need custom static error pages to be shown.
Has anyone managed to achieve this?
TIA
I ended up making my error page controller methods return a status of 200 (OK), unless dealing with an AJAX request:
class ErrorController {
def pageNotFound() {
if (!request.xhr){
response.status = 200
}
}
}
IIS is set to 'Custom error pages'.
This prevents IIS stepping in and providing the custom static pages that I provide, unless the requested URL is outside the scope of the Grails application.
The error status is retained for AJAX requests in order to allow the caller to properly deal with the result.
I'm unsure whether it's satisfactory practice to return 200 from the application on error, particularly with regard to search engines - however it seems that even without this change, when an error occurs and the response is ultimately returned to the browser from IIS it has a status of 200, according to Fiddler.

Mochahost GWT rpc and Servlet not working

While deploying my app to mochahost, I met the problem between servlet and GWT-RPC communicate. The error shows:
HTTP Status 404 - /403.shtml
type Status report
message /403.shtml
description The requested resource (/403.shtml) is not available.
.war file works perfectly on my workstation, but not working on mochahost.
Any ideas to solve it?
Thanks in advance.
Mochahost have a very good support, try livechatting with their tech department, you will probably have the thing solved.
That's what I do.
Make sure you update live site URL. For instance, generally, on local system you access web app as http://localhost:8080/myapp but, on server it changes to http://[www.]myapp.com. Again, this is just an instance. The point is, the live site must reflect correct URL from code (servlet/JSP/action/etc...) and configuration properties, if any.
Comment 'DirectoryIndex' property in .htaccess file if you do not have any index file.
Comment 'RewriteCond' property in .htaccess file if you do not have any rewrite requirement.
For sure, one of the reason - if client does not accept cookies and servlet does not encode URL.

Categories