• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

placing and configuring web.xml, servlets not available

 
james smitho
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. Well, I start a new topic. I want to make sure these 4 things.

So, all my java.files - including - servlets and one build.xml are in web-inf/src/package MyProject

But just to make sure;

1. I have three servlets and I have to make three web.xml.files, right?

2. And Like this;

?xml version="1.0" encoding="ISO-8859-1"?>
<!--<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd"> -->

<web-app>
<servlet>
<servlet-name>S2</servlet-name>
<servlet-class>This is my project</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>S2</servlet-name>
<url-pattern>/This is my project</url-pattern>
</servlet-mapping>
</web-app>


Is this correct?, servlet is S2 and when I open that with a web browser it says, This is my project.



3. AND WHERE I PUT THESE THREE WEB.XML.FILES?



4. AND probably when I have done those things, a problem;

now I have also S3 in WEB-INF/classes.

A web browser says about S3;

The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Cannot allocate servlet instance for path /tomcat//MyProject/servlet/S3
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:388)
org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:133)
....
root cause

java.lang.NoClassDefFoundError: S3 (wrong name: S2/S3)



will disappear, right??
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
james smitho wrote:So, all my java.files - including - servlets and one build.xml are in web-inf/src/package MyProject
For the 4th time. Bad idea. Keep your sources out of the web app. And it's WEB-INF, not web-inf.

1. I have three servlets and I have to make three web.xml.files, right?
Wrong. One.

<servlet-class>This is my project</servlet-class>
Huh? This should be the fully-qualified class name for your servlet.

<url-pattern>/This is my project</url-pattern>
Don't use spaces in the mapping.

3. AND WHERE I PUT THESE THREE WEB.XML.FILES?
Don't post in all uppercase. And only one web.xml placed in WEB-INF.

And for the final time, use code tags when posting code. You've been asked often enough. Future posts with unformatted code will be ignored.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And lastly, please come up with better topic titles than "web.xml".
 
Rok Ć telcer
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


1. I have three servlets and I have to make three web.xml.files, right?

No. Each Web app has only one web.xml DD.

<servlet-class>This is my project</servlet-class>

Hm, at this point I would have to say that it makes no sense to answer your question.

I'd suggest that you read some books first (Head first ...).
According to your previous post (package problem), you should start with e.g. Head First Java.

You have to know (master) the bases first ... sorry, but that just the way it is!


Regards,
Rok
 
james smitho
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All right, I'm sorry. Thanks again for answering.

Ok, One web.xml.

And it is;



Now right?


And I just put that one
web.xml in WEB-INF/


But still a web browser says ( S2 works fine ) about S3;





Hey, last minute change;

This is strange. Now that announcement has gone and now both servlets, S2 and S3, - a web browser says;




What have I done wrong?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my last post: you have been told again and again that servlets need to be placed into a package. Yet you either refuse to do it, or don't know how. If the latter, I suggest stepping back and learning basic Java before trying to do servlets.
 
james smitho
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please. Servlets are in a package, I just checked again, they are. I tried to do just like you adviced!

They are in package MyProject. I wrote that "is not available" line in a hurry.

Only thing that I can think is that web.xml configuration is wrong?

I want this thing work and I don't ask new questions anymore. I just wanted help and this is forum. I'm sorry.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
james smitho wrote:Please. Servlets are in a package, I just checked again, they are. I tried to do just like you adviced!

It is not reflected here:
This must be the fully-qualified name of the class, including its package.

They are in package MyProject. I wrote that "is not available" line in a hurry.
Package names should be all lower case.

Only thing that I can think is that web.xml configuration is wrong?
Yes. As stated above.

I want this thing work and I don't ask new questions anymore. I just wanted help and this is forum. I'm sorry.
No need to be sorry, but you don't seem to be taking the help that you are getting very seriously. That's the best way to get people to start ignoring your posts.

Take what's written carefully, and be sure to apply it. How many times have I told you to remove the sources from WEB-INF? Not that they'll cause problems, but they just don't belong there.

And until your web.xml is correct, there's no hope of anything working.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic