aspose file tools*
The moose likes Servlets and the fly likes What's wrong with this deployment descriptor? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "What Watch "What New topic
Author

What's wrong with this deployment descriptor?

Vishal Sheokand
Greenhorn

Joined: Nov 29, 2010
Posts: 7
<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0"
metadata-complete="true">

<servlet>
<servlet-name>S1</servlet-name>
<servlet-class>MyServlet1</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>S1</servlet-name>
<url-pattern>/gotoS1</url-pattern>
</servlet-mapping>

<filter>
<filter-name>F1</filter-name>
<filter-class>MyFilter1</filter-class>
</filter>

<filter-mapping>
<filter-name>F1</filter-name>
<servlet-name>S1</servlet-name>
</filter-mapping>


</web-app>

-->Logs show error in mapping servlet with url-pattern:invalid url-pattern.
Vishal Sheokand
Greenhorn

Joined: Nov 29, 2010
Posts: 7
Now a warning is generated :
WARNING: Failed to process TLD with path [htp://tamcat.apache.org/example-taglib] and URI [/WEB-INF/jsp/example-taglib.tld]
java.net.MalformedURLException
at java.net.URL.<inti><Unknown Source>
.
.
.
and so on.....

after that-->
SEVERE: Error listenerStart

SEVERE:Error fileterStart -->in deploying web application directory project(project is the folder where all my files including MyServlet1.java,.class and MyFilter1.java,class and all other jsp files are)


Aditya Jha
Ranch Hand

Joined: Aug 25, 2003
Posts: 227

I haven't tested it, but probably URL pattern shouldn't start with a '/'. Try '*' in place of that.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61610
    
  67

Please use code tags and post errors as text, not screen shots.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vishal Sheokand
Greenhorn

Joined: Nov 29, 2010
Posts: 7
I haven't tested it, but probably URL pattern shouldn't start with a '/'. Try '*' in place of that.


Thats probably '*/something' you are talking about....
i have seen examples too the pattern is exactly same..the pages load fine when i replace my web.xml with some web.xml of example(of course servlets and filters don't work then,,but atleast first page opens and project starts)..any other suggestion??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61610
    
  67

Aditya Jha wrote:I haven't tested it, but probably URL pattern shouldn't start with a '/'. Try '*' in place of that.

Completely incorrect. You cannot start a URL pattern with a *.

Please post the web.xml and errors in clear text and using code tags. I will not, repeat not, download images to look at error messages or code.

If you want help, you're going to need to put in some effort of your own.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12823
    
    5
In addition, you have made the common beginner error of not using a package:



All classes used in servlets MUST be in a package and the class files located accordingly. The reason is that with no package, the JVM tries to load from the "current" directory - something you have no control over in the servlet environment.

See this FAQ on the dreaded invoker servlet

Bill
Vishal Sheokand
Greenhorn

Joined: Nov 29, 2010
Posts: 7
Please post the web.xml and errors in clear text and using code tags. I will not, repeat not, download images to look at error messages or code.

If you want help, you're going to need to put in some effort of your own.

Sorry I am new at Servlets and I really had no idea what was inside log folder of Tomcat Directory.



Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18886
    
    8

Why does your <filter-mapping> element have a <servlet-name> element under it?
Vishal Sheokand
Greenhorn

Joined: Nov 29, 2010
Posts: 7
o...i guess packaging may still be wrong..
May be i should spend few more hours on where to put the package and files.I'll be back with new failed tries.Currently foo package is in the "project" directory itself,where all other files are.
Vishal Sheokand
Greenhorn

Joined: Nov 29, 2010
Posts: 7

Why does your <filter-mapping> element have a <servlet-name> element under it?

What else are you expecting?

The project finally did started.But still filter is not starting up.It gives error-->The requested resource (/gotoS1) is not available.



web.xml is same as above.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18886
    
    8

Vishal Sheokand wrote:

Why does your <filter-mapping> element have a <servlet-name> element under it?

What else are you expecting?


My <filter-mapping> elements always have <url-pattern> elements under them. I ask you again, why does yours have a <servlet-name> element?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61610
    
  67

A servlet-name is a viable way to map a filter.

This thread has meandered so much, I'm not even sure what the problem is in the first place at this point.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18886
    
    8

Bear Bibeault wrote:A servlet-name is a viable way to map a filter.

I didn't know that. I haven't ever considered mapping specific servlets to a filter and it's not something I would be likely to do.
This thread has meandered so much, I'm not even sure what the problem is in the first place at this point.

Yeah. There was some talk about URL patterns earlier but that was based on the unreadable images.
Vishal Sheokand
Greenhorn

Joined: Nov 29, 2010
Posts: 7

My <filter-mapping> elements always have <url-pattern> elements under them. I ask you again, why does yours have a <servlet-name> element?


Because I am studying Servlets and JSPs and my book says its within options-You can either use url-pattern OR servlet-name for small apps.And it works fine in NetBeans IDE but I am trying to learn the things so I am using Tomcat therefore getting so much trouble.


This thread has meandered so much, I'm not even sure what the problem is in the first place at this point.


Yes.I am not sure if I should start a new thread for this.Actually my project wasn't starting at all earlier,then William told me to put my classes in package.It finally started,but now the problem is that filter is not starting,and as soon as I click on the button that calls the servlet with which filter is attached, it gives error-->requested source not found.
Aditya Jha
Ranch Hand

Joined: Aug 25, 2003
Posts: 227

@Bear Bibeault

Completely incorrect. You cannot start a URL pattern with a *.

That's odd. I have always used the following with Struts.


I'm pretty sure many others would have done the same.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61610
    
  67

That's obviously not what I meant. You cannot start a path-style pattern with *.

The file-type style is rather outdated and out of favor.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What's wrong with this deployment descriptor?