开发者

Host files on Tomcat possible?

开发者 https://www.devze.com 2022-12-23 23:07 出处:网络
I have a Tomcat 6.0.24 server running. I\'m using to run some JSP pages. Would it be possible to host files on it? E.g. If I type in http://localhost:8080/Sample.avi I would download Sample.avi? Proba

I have a Tomcat 6.0.24 server running. I'm using to run some JSP pages. Would it be possible to host files on it? E.g. If I type in http://localhost:8080/Sample.avi I would download Sample.avi? Probably there are better servers I guess for this task, but I'd li开发者_开发技巧ke to stick to Tomcat since I don't wish to install another server. Is it possible?

Thanks and regards, Krt_Malta


It's possible: simply add a <Context> in the server.xml file to point to the directory containing you files.


Yes, it's possible. A quick google suggests you need a StaticInterceptor

What you call "files" is usually called "static content" in web terms: a fixed resource at a specific URI.


If you are using IntelliJ,

  1. Place the static files that you want to host in a folder.
  2. Launch IntelliJ -> Select Tomcat -> Edit Configuration -> Deployment -> + -> External Source -> Select the above folder and set the application context (For e.g. static)
  3. You can access the files with http://localhost:// (For e.g. http://localhost:8080/static/static_image.png)

IntelliJ setup

0

精彩评论

暂无评论...
验证码 换一张
取 消