Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2005

Tip: Looking for answers? Try searching our database.

jsps, images and a catch-all in the web.xml file

Thread view: 
subscriptions@easypeas.net - 11 Oct 2005 14:22 GMT
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
Andrea Desole - 11 Oct 2005 14:56 GMT
> which works just fine, but is a total hack.  What's the preferred way
> of doing something like this?

have you considered a servlet filter? That looks like a good place for
your catch-all url map
subscriptions@easypeas.net - 11 Oct 2005 16:02 GMT
I think you're right.  They look good for what I need...thanks!

Walter


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.