permaculture playing cards*
The moose likes Servlets and the fly likes Context problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Context problem" Watch "Context problem" New topic
Author

Context problem

Adrien Ruffie
Ranch Hand

Joined: Jan 14, 2009
Posts: 90
Hello all,

I have a problem and I don't know the best way to do that.

The context: I have a webapp where I save, delete, update "server" and "user" from my webapp
in a file under /WEB-INF/classes/datafile.xml

Imagine I log me on the webapp as "administrator/administrator" (login/password), after that I
modify server informations then the webapp rewrite my datafile.xml under /classes in order to
update the modified informations for one server.

But when the datafile.xml is rewritten the web server reload the context and when the
web application being reloaded, all sessions are delete so requiring users to identify themselves again.

Anyone know the best practice for this case ?

I have found session-time out parameter in web.xml, but in this case it isn't a timeout ...

I have also found this "reloadable" attributes in tomcat configuration:

<Context docBase="myapp-ui" path="/myapp-ui" reloadable="true" source="org.eclipse.jst.j2ee.server:myapp-ui" debug="0">


SCJP 5, SCDJWS 5
http://adrien-ruffie.blogspot.com
Pete Nelson
Ranch Hand

Joined: Aug 30, 2010
Posts: 147

Is there a reason you're writing to the "classes" folder? I suspect the reason it's reloading everything is because it's seeing a change to that folder.

Typically, if I have to write data to a local file, I either use a "WEB-INF/data" folder, or a folder completely outside of my webapp.


OCPJP
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

Pete is giving you good advice. Never write to the /classes folder. In fact, it's best to not write anywhere in the web app at all. Follow the advice of writing somewhere outside the app. That way, you don;t need to worry about what happens to the files when you redeploy the app.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Adrien Ruffie
Ranch Hand

Joined: Jan 14, 2009
Posts: 90
Thank you for your response, but can I write for example under /WEB-INF/data and not in /WEB-INF/classes without the application doesn't reload ?

Because you suggestion to write outside app for example in /home/myuser require to be configured when the application deployment, but unfortunately

I shouldn't have to make deployment configuration for my product ...


Thank you again,

Adrien
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

Adrien Ruffie wrote:Thank you for your response, but can I write for example under /WEB-INF/data and not in /WEB-INF/classes without the application doesn't reload ?

Yes.

Because you suggestion to write outside app for example in /home/myuser require to be configured when the application deployment, but unfortunately

No. The whole point of writing outside the web app is that the file isn't configured as part of the web app. That way, it doesn't get in the way of, or get trounced by, future deployments.

You'd serve the file via a servlet that reads and streams the file from its external location.
Adrien Ruffie
Ranch Hand

Joined: Jan 14, 2009
Posts: 90
Thank you Bear Bibeault,

I take the first solution to write under /WEB-INF/data for example
 
GeeCON Prague 2014
 
subject: Context problem