File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Translation tool in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Translation tool in java" Watch "Translation tool in java" New topic

Translation tool in java

Mathias Nilsson
Ranch Hand

Joined: Oct 13, 2003
Posts: 107
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

SCJP2 , MCP( 70-229 ) , Preparing For SCWDC
Kevin Jones
Ranch Hand

Joined: Oct 29, 2003
Posts: 39
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");

Kevin Jones<br />Author: <a href="" target="_blank" rel="nofollow">Servlets and JSP: The J2EE Web Tier</a>
Mathias Nilsson
Ranch Hand

Joined: Oct 13, 2003
Posts: 107
My english is a little weak. "ServletContext" what does that mean exactly?
// Mathias
I agree. Here's the link:
subject: Translation tool in java
jQuery in Action, 3rd edition