• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Context problem

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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">
 
Ranch Hand
Posts: 147
Eclipse IDE Tomcat Server Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Adrien Ruffie
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Bear Bibeault,

I take the first solution to write under /WEB-INF/data for example
reply
    Bookmark Topic Watch Topic
  • New Topic