S
subscriptions
I'm writing a JSP/Servlet web-app for transforming mnemonics into URLs,
similar to what http://tinyurl.com does. In other words, if the
mnemonic "xyz" points to http://google.com, then entering
http://example.com/xyz (where example.com is my website) would
automatically redirect to Google.
I figured I could use a catch-all url map in order to analyze the
indicated mnemonic. But how do I access the static elements of the
web-app? For instance, say I have a gif on the site, icon.gif. How
could I reference it? I could use an image servlet, mapped so:
<servlet>
<servlet-name>imageLoader</servlet-name>
<servlet-class>com.example.ImageLoaderServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>imageLoader</servlet-name>
<url-pattern>*.gif</url-pattern>
</servlet-mapping>
but if the image is in the base directory, loading it via
HttpServletRequest.getRequestDispatcher(String) results in an endless
loop.
For text files I've been using a mapping like:
<servlet>
<servlet-name>stylesCss</servlet-name>
<jsp-file>/styles.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>stylesCss</servlet-name>
<url-pattern>styles.css</url-pattern>
</servlet-mapping>
which works just fine, but is a total hack. What's the preferred way
of doing something like this?
Thanks,
Walter Gildersleeve
Freiburg, Germany
similar to what http://tinyurl.com does. In other words, if the
mnemonic "xyz" points to http://google.com, then entering
http://example.com/xyz (where example.com is my website) would
automatically redirect to Google.
I figured I could use a catch-all url map in order to analyze the
indicated mnemonic. But how do I access the static elements of the
web-app? For instance, say I have a gif on the site, icon.gif. How
could I reference it? I could use an image servlet, mapped so:
<servlet>
<servlet-name>imageLoader</servlet-name>
<servlet-class>com.example.ImageLoaderServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>imageLoader</servlet-name>
<url-pattern>*.gif</url-pattern>
</servlet-mapping>
but if the image is in the base directory, loading it via
HttpServletRequest.getRequestDispatcher(String) results in an endless
loop.
For text files I've been using a mapping like:
<servlet>
<servlet-name>stylesCss</servlet-name>
<jsp-file>/styles.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>stylesCss</servlet-name>
<url-pattern>styles.css</url-pattern>
</servlet-mapping>
which works just fine, but is a total hack. What's the preferred way
of doing something like this?
Thanks,
Walter Gildersleeve
Freiburg, Germany