Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Translation tool in java

 
Mathias Nilsson
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!
I'm using jsp,servlets,tomcat 4 to develop a webapplication. The application
can be accessed in many languages. I used to develop my applications
in asp , com before and there I could make an application object i global.asa load text from the database into the object and use it to gain
text from the object. If let's say the user clicked the US flag then english text could be retrieved from the object.
I used this so that I wouldn't have to access the database for every word
printed on the page. My question is. How do I do this in java.

I'm now using classes from Collection package and populates the collection
from the database. Now how can I store the my class in memory so that I can get data from my class not using new. i don't want to get the data from the database, just from the object!
// Mathias
 
Kevin Jones
Author
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the ServleteContext.
In your servlet do ServletConext sc = getServletContext();
then you cam store object references in the ServletContext like this
MyDataObject mdo = new MyDataObject();
sc.setAttribute("foo", mdo);
then to retrieve the data
MyDataObject mdo2 = (MyDataObject)sc.getAttribute("foo");
 
Mathias Nilsson
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
My english is a little weak. "ServletContext" what does that mean exactly?
// Mathias
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic