File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problems about "web.xml"

 
Karn Sadyapongse
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Karn Sadyapongse
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
instead of using <url-pattern>/</url-pattern>
use <url-pattern>/*</url-pattern>

This will solve your problem
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3830
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic