aspose file tools*
The moose likes Servlets and the fly likes placing and configuring web.xml, servlets not available Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "placing and configuring web.xml, servlets not available" Watch "placing and configuring web.xml, servlets not available" New topic
Author

placing and configuring web.xml, servlets not available

james smitho
Ranch Hand

Joined: Nov 16, 2009
Posts: 32
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

Joined: Jan 10, 2002
Posts: 61761
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

And lastly, please come up with better topic titles than "web.xml".
Rok Štelcer
Ranch Hand

Joined: Nov 03, 2009
Posts: 101
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


SCJP, SCWCD
james smitho
Ranch Hand

Joined: Nov 16, 2009
Posts: 32
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

Joined: Jan 10, 2002
Posts: 61761
    
  67

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

Joined: Nov 16, 2009
Posts: 32
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

Joined: Jan 10, 2002
Posts: 61761
    
  67

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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: placing and configuring web.xml, servlets not available