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

url pattern

misun chung
Greenhorn

Joined: Oct 07, 2004
Posts: 1
Hello?

I got a problem with url pattern.
Here is my web.xml.
As you can see, I have two servlets, one for log-in and one for controlling the jsp pages. (test is the directory name of this application)
If I enter the url, "http://localhost:8080/test/SessionLogin" or "http://localhost:8080/test/ControllerServlet",
it works fine.
But I would like to use "http://localhost:8080/test"!

I tried several things, and found out that if I edit the url-pattern of either servlet like
"
<url-pattern>/</url-pattern>
"
then, I can't use relative path for images or styles.
For example,
I have the following codes in a jsp page.
"<!-- styles -->
<LINK REL="StyleSheet" HREF="style/style.css" TYPE="text/css" MEDIA=screen>
"

Any suggestion would be appreciate!!!
Thanks!

----------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<display-name>Intranet System </display-name>


<description>
Welcome!
</description>


<servlet>
<servlet-name>SessionLoginServlet</servlet-name>
<servlet-class>SessionLoginServlet</servlet-class>
</servlet>

<!-- Define the controller servlet -->
<servlet>
<servlet-name>ControllerServlet</servlet-name>
<servlet-class>ControllerServlet</servlet-class>
</servlet>


<!-- Define the controller servlet -->

<servlet-mapping>
<servlet-name>SessionLoginServlet</servlet-name>
<url-pattern>/SessionLoginServlet</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>ControllerServlet</servlet-name>
<url-pattern>/ControllerServlet</url-pattern>
</servlet-mapping>



<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>



<!-- Security roles referenced by this web application -->
<security-role>
<role-name>role1</role-name>
</security-role>
<security-role>
<role-name>tomcat</role-name>
</security-role>


</web-app>
----------------------------------
[ October 07, 2004: Message edited by: misun chung ]
Manoj Gundawar
Ranch Hand

Joined: Nov 17, 2002
Posts: 169
I am not sure why you are doing that. May be you have your own reason. But
try using absolute path for images and CSS in your JSPs.
Ex. /APP_NAME/folder_name_of_CSS/Actual_Name_Of_CSS_File
[ October 07, 2004: Message edited by: Jmannu gundawar ]

Manoj<br />SCJP, SCJD, SCWCD, IBM WSAD.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: url pattern