| Author |
problems about "web.xml"
|
Karn Sadyapongse
Greenhorn
Joined: Jan 09, 2006
Posts: 13
|
|
details in my webm.xml is ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ <servlet> <servlet-name>InitialServlet</servlet-name> <servlet-class>Initialize.InitialServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>InitialServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ to start my web application i type "http://127.0.0.1:8080/myProject/" then it will call Initialize.InitialServlet to start my web app (because i use <url-pattern>/ ("/" means root,isn't it?) then i found one problem that my pictures and my css can't be found ( can't be call ) so i tried to call pictures directly such as "http://127.0.0.1:8080/myProject/images/myButton.jpg" instead of showing "myButton.jpg" on the screen,it send me to "http://127.0.0.1:8080/myProject/" and run "Initialize.InitialServlet" i don't know how to fix this problem is anything wrong with my logic??? thanks pal [ January 10, 2006: Message edited by: Bear Bibeault ]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56202
|
|
Rather than trying to map "/" -- not a good idea as you have discovered -- I'd add the servlet (using a more reasonable mapping) the the welcome-file list so that "/" will invoke it. [ January 10, 2006: Message edited by: Bear Bibeault ]
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Karn Sadyapongse
Greenhorn
Joined: Jan 09, 2006
Posts: 13
|
|
thanks yes,if i change the first servlet into something else such as "<url-pattern>/home</url-pattern>" then "http://127.0.0.1:8080/myProject/home" errors will not occured but my manager said that he want to type only "http://127.0.0.1:8080/myProject/" when start the web application so that i tried to fix the problem while i still type only "http://127.0.0.1:8080/myProject/" help me please,thanks
|
 |
Abhinit Saxena
Greenhorn
Joined: Jan 10, 2006
Posts: 18
|
|
instead of using <url-pattern>/</url-pattern> use <url-pattern>/*</url-pattern> This will solve your problem
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56202
|
|
Originally posted by Karn Sadyapongse: but my manager said that he want to type only "http://127.0.0.1:8080/myProject/" when start the web application
Read what I wrote again.
|
 |
ankur rathi
Ranch Hand
Joined: Oct 11, 2004
Posts: 3829
|
|
Originally posted by Karn Sadyapongse: thanks yes,if i change the first servlet into something else such as "<url-pattern>/home</url-pattern>" then "http://127.0.0.1:8080/myProject/home" errors will not occured but my manager said that he want to type only "http://127.0.0.1:8080/myProject/" when start the web application so that i tried to fix the problem while i still type only "http://127.0.0.1:8080/myProject/" help me please,thanks
As Bear said, use welcome-file-list tag.
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Originally posted by Abhinit Saxena: instead of using <url-pattern>/</url-pattern> use <url-pattern>/*</url-pattern> This will solve your problem
False. This will not solve the problem. You don't want to overide the default servlet handling for requests to static resources. Read Bear's solution.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
 |
|
|
subject: problems about "web.xml"
|
|
|