Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

servlet 404 Error  RSS feed

 
Xenia Yanish
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, everyone! I'm new in java and I need your help. The program makes connection to database. When I'm running the application, there is next error:



Help me, please!
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

What is the full URL you're trying to access, and how have you mapped /servlet/Connect to a servlet in the web.xml file?
 
Xenia Yanish
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Welcome to JavaRanch.

What is the full URL you're trying to access, and how have you mapped /servlet/Connect to a servlet in the web.xml file?


I tried http://localhost:8080/Connect/ and http://localhost:8080/servlet/Connect/, but it doesn't works.
Here's the web.xml:
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The former will only work if this web app is the ROOT web app - which would be a very unusual setup. The latter will work if the web app is named "servlet" - is that the case?

Also, the servlet mapping says "/ConnectUI", not "/Connect".
 
Xenia Yanish
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Also, the servlet mapping says "/ConnectUI", not "/Connect".

unfortunately, it's not changing anything
"/Connect" - this is because the project called "/Connect" and an app "/ConnectUI", I forgot to change it, when created maybe that's causes?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the project is called "Connect" -and I interpret "project" to mean "web app"- then the URL would be /Connect/ConnectUI
 
Xenia Yanish
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:If the project is called "Connect" -and I interpret "project" to mean "web app"- then the URL would be /Connect/ConnectUI

not helping, I think maybe it's because I have constructor, but it should be
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now I'm really confused, and -I suspect- so are you :-)

For starters, remove any and all constructors any of your servlet classes has. You should never add any constructors to a servlet. Whatever initializations you need to make go in the init(ServletConfig) method.

If by "Servlet" you mean javax.servlet.Servlet then you can't extend that - it's an interface, not a class. The majority of servlets extends javax.servlet.http.HttpServlet - unless you know of good reasons why your servlet should extend some other class, that's what you should go with.

BUT! None of this has anything to do with mapping a servlet to a URL and accessing it.
 
Xenia Yanish
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At first I created a table with Vaadin-framework and of course it became "extends UI", and now I want to add a connection to database to this app. What should I do?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We like to keep topic to a single subject, so let's concentrate on the 404 issue here. For any Vaadin-specific questions (like how to use it a DB) please start a new topic in the Other Application Frameworks forum.

As to the servlet extending classes - OK, that's a good reason why your servlet should extend some other class :-)

But that doesn't really address the issue. I can only repeat what I said earlier:
If the project is called "Connect" -and I interpret "project" to mean "web app"- then the URL would be /Connect/ConnectUI

From what you posted it sounds like the web app is named "Connect" - is that corrrect? Do you understand what the consequences are that the name of a web app has in terms of the directory structure and its URL? And the web.xml you posted maps the URL "/ConnectUI" to the publisher.com.ConnectUI servlet. If that's both accurate, then the URL is "/Connect/ConnectUI" - have you tried that?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!