• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

web.xml url-pattern wildcard not working in Tomcat6

 
David Corleson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34218
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
David Corleson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne, I threw the package path in there real quick. Correct, the servlet name is in uppercase on my application.
 
Misha Ver
Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David Corleson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, good point
 
David Corleson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is fragile and a poor way to address the resources. See the JSP FAQ for the foolproof way.
 
David Corleson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the suggestion, Bear. I've made the change to my code based on the JSP FAQ. Good stuff here!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic