java web什么东西放application中好,如何刷新Java Web Application中的静态资源?

I am developing an application that stores data dynamically and displays it as it is generated or uploaded. But the problem is when I am uploading any image then it should be displayed. It's path is also defined perfectly but until I refresh the whole application in eclipse it remains unchanged.

So to update application, I have to refresh it.

My application is Java based and is useing JSP and Servlet. Is there any code that can be used to update or refresh the application?

Right now I am doing it by right click -> refresh or directly F5 it.

Or suppose I want to create directory then where will I have to create it that will be accesses easily without refresh.

When I'll host my application then which place is better for to store data?

I know it's outside the web app but any specific place? Because there is no drive so how can I create or make directory and access that one in my code.

解决方案

Is there any code that can be used to update or refresh the application?

Right now I am doing it by right click -> refresh or directly F5 it.

I think you need to look into the workspace re-fresh option in Eclipse ( was made available from Eclipse version 3.7.x ). You can enable it in Preferences > General > Workspace and select Refresh on access or as per need you can change to whatever setting you require.

VpuuY.png

When I ll host my application then which place is better for to store data ? I know it's outside the web app but any specific place ? Because there is no drive so how can I create or make directory and access that one in my code.

The location of static content is best if placed outside of the scope of the project itself. Maybe some other directory on your server ( be it any directory ).

I can share what I have normally seen as a trend in different applications that I have personally worked on. We had a separate tomcat server that just hosted all static content ( all media ) and our web application accessed that static-server (as it was named) within a secured network. All hits to static content could only be made via our application server and thus all direct hits were either rejected or not entertained at all.

Edit

I would suggest using a an absolute path

and on windows environment

you will HAVE to use the drive lletter

and specify the path as X:\some\path

if you want to hide your letter drive

due to obvious security reason

I can suggest another idea

Idea 1 : Make a separate drive (lets call it drive F) and make a folder with the name of "static". Then in your application , you just forward all requests to file uploads using this path ( F:\static......) . I would advise loading the directory name from a property file instead of hard-coding it in your code

Idea 2 : If you cant make a separate drive, then make a directory namely "static" on the root of same drive ( C:\static ) . Make a user group and give him read/write permissions on this drive and revoke writing permissions from this user on all other drives ( just in case someone messes up with this user-group). Next do the same thing as above i.e specify this path into your application. One thing is that you would have to run your application with that specific user-group to ensure that the permissions security you have setup can be implemented.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值