You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Konstantin Kolinko <kn...@gmail.com> on 2012/04/07 18:10:54 UTC

Re: Accessing USB drive content from pages served from tomcat6 server

2012/4/7  <so...@wipro.com>:
> Hello Chris,
>
> Thanks a lot for responding to my post.
>
> [Chris]What do you mean "not able to access its content"? Do you get 404s?
> 500s? Does the thread hang? Does the JVM crash?
>
> [Souvik]: When I am trying to access the content of usb_1, I am getting 404 error.
> Here are the details:
> HTTP Status 404
> message < This is blank>
> description The requested resource () is not available.
>
> [Souvik]
>
> [Chris]Q:What about starting Tomcat with no USB devices, then trying to access the resources, then attaching the devices and trying again?
> Ans: Only usb_0 works.
>
> [Chris]Q:What happens when both devices are connected *before* you start Tomcat?
> Ans: Only in this case I could access both the devices.
>
> [Chris] Honestly, I'm not sure why you'd want to run a web server off a device
> which isn't guaranteed to be available.
>
> [Souvik] Actually I am developing a HTML5 App which would run on an embedded target. One of the functionalities of the application is to allow user to playback and browse the media content available in an USB stick. Since I am using Webkit browser so some features of HTML5 do not run from file:// url and therefore the pages need to be served from a local web server. I have chosen tomcat for that.
>
> So it seems to achieve my goal, I need to first connect usb sticks to all the available usb ports on my target and then start tomcat6. As mentioned by you,is the server keeping this information in the cache so that in future when a USB device is connected to a port, it is able to make that out?
> Is this understanding correct?

1. You are (ab)using Tomcat Autodeployment feature.

If docbase of a webapp is not readable, it really cannot start. (Just
a guess. If you looked at the logs your would see it more clearly).

2. It is possible to control deployment process via JMX. That is to
deploy new contexts when needed - the Manager webapp does that.

But I think that using contexts to display those USB sticks is not a
good thing. One thing to beware is that when application is undeployed
 all its contents is deleted (so you risk to delete all data from that
USB stick).

I think it would be better to write a servlet that will serve static
files from the stick. It should not be hard. It might be based on
Tomcat's DefaultServlet,  but actually yours can be more simple:

1. You do not need to use servlet API to get the resources. You have
to use direct file access using java.io.
2. Your access is read-only. You do not need to support writing.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org