aspose file tools*
The moose likes Servlets and the fly likes web.xml url-pattern wildcard not working in Tomcat6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "web.xml url-pattern wildcard not working in Tomcat6" Watch "web.xml url-pattern wildcard not working in Tomcat6" New topic
Author

web.xml url-pattern wildcard not working in Tomcat6

David Corleson
Greenhorn

Joined: Feb 26, 2010
Posts: 8
Hi all

I have a servlet-url mapped with a wild card in Tomcat 6 ---> /path/*

if I hit the url http://localhost:8080/nameOfProject/path/hello?var1=hi&var2=there then I get an error "the requested resource is not available".

http://localhost:8080/nameOfProject/path -----> Works

I'm using Eclipse with the Sysdeo Tomcat plug-in and the project's xml file under %CATALINA_HOME%\conf\Catalina\localhost reads '<Context path="/path" ...'

What gives? According to "Head First Servlets and JSP" chapter 11, it says this should work.

Thanks in advance !

Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31079
    
163

Are you sure "com.coderanch.forum.test" is the full name of your servlet class? Traditionally class names are uppercase so I'd expect to see com.coderanch.forum.Test or com.coderanch.forum.test.MyServlet


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
David Corleson
Greenhorn

Joined: Feb 26, 2010
Posts: 8
Jeanne, I threw the package path in there real quick. Correct, the servlet name is in uppercase on my application.
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
David Corleson wrote:Jeanne, I threw the package path in there real quick. Correct, the servlet name is in uppercase on my application.


http://faq.javaranch.com/java/PostRealCode
David Corleson
Greenhorn

Joined: Feb 26, 2010
Posts: 8
Thanks for the etiquette messages folks, i've rec'd a couple now and have corrected things. Hoping we can move toward a solution to the problem if there are suggestions.

thanks!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61768
    
  67

It's a lot more than etiquette. Programming is a matter of accuracy and precision. You should show as much attention to detail within your posts as you do to your code. If you get a reputation as someone who wastes people's time with red herrings due to sloppy posting, you may not get all the help you can.

Perhaps you should post your Servlet code, your deployment descriptor and the location of the class file.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Corleson
Greenhorn

Joined: Feb 26, 2010
Posts: 8
ok, good point
David Corleson
Greenhorn

Joined: Feb 26, 2010
Posts: 8
I think I'm supplying the proper info now. I'm trying to set up a servlet that can be accessed from a wild card mapping. Please see my code snippets below.
(servletBase is the context)

It displays correctly if I hit: http://localhost:8080/servletBase/doc?id=56
The jsp displays the properly coded error with: http://localhost:8080/servletBase/doc
Many, many doGet exceptions, to the point of stack overflow with: http://localhost:8080/servletBase/doc/
Same as above, but this is my desired url structure (where 'item' can be anything): http://localhost:8080/servletBase/doc/item?id=65

web.xml


servlet code


jsp code


ERROR
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61768
    
  67

java.lang.StackOverflowError

OK, that usually means you have a recursive routine that's not ending, or another infinite loop of some type.

Are you recursively forwarding to the same servlet?
David Corleson
Greenhorn

Joined: Feb 26, 2010
Posts: 8
Thanks Bear for sticking with me to find an answer.

I came to realize I was missing one character in my servlet code.

There needs to be a forward slash in the path to my jsp page.



should read:


Hope this helps someone in the future!

-thanks
David Corleson
Greenhorn

Joined: Feb 26, 2010
Posts: 8
Additionally, to make the assets (css/js/images) load for the desired url: http://localhost:8080/servletBase/doc/item?id=65

I needed to prepend "../" to the path of each asset.

e.g.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61768
    
  67

That is fragile and a poor way to address the resources. See the JSP FAQ for the foolproof way.
David Corleson
Greenhorn

Joined: Feb 26, 2010
Posts: 8
Thanks for the suggestion, Bear. I've made the change to my code based on the JSP FAQ. Good stuff here!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: web.xml url-pattern wildcard not working in Tomcat6