aspose file tools*
The moose likes Servlets and the fly likes Accessing Tomcat Memory in command line. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Accessing Tomcat Memory in command line." Watch "Accessing Tomcat Memory in command line." New topic
Author

Accessing Tomcat Memory in command line.

Bennet Xavier
Ranch Hand

Joined: Jun 19, 2008
Posts: 162
Hi All,

i need to access the memory of Tomcat server through command line program

i have swing based application, which need to access the information in the tomcat memory.

if, i store application.setAttribute("A",new Object()) in jsp, can i get the attribute A in swing application, is it possible?

please help me, it very urgent for me do this type of programming.

Thanks and Regards,

Bennet Xavier X
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42612
    
  65
Do you need to transfer the actual Java object? If so, you could use serialization over HTTP. Be aware that the JVM versions generally need to match on both ends for that to work.

If your objects have JavaBean characteristics you could transfer the XML that is generated by the java.beans.XMLEncoder class.


Ping & DNS - my free Android networking tools app
Bennet Xavier
Ranch Hand

Joined: Jun 19, 2008
Posts: 162
Hi,

as of now, i don't want to transfer the objects from web application to command line.

i just need to refer the object that are in tomcat container.

do reply.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42612
    
  65
What do you mean by "refer the object"? There's no such thing as having a reference to an object that lives in another JVM (unless you want to get into RMI or some such technology - do you?). Maybe you can explain in more detail what you're trying to achieve.

do reply.

That sounds a bit as if an order is given ... probably not what you intended.
Bennet Xavier
Ranch Hand

Joined: Jun 19, 2008
Posts: 162
"do reply" mean that means please accept my apologize and "I AM REALLY SORRY"...

as i explained earlier, if i say application.setAttribtue("A", new String("A")) in jsp. can i get the attribute A in a swing application which is running in the same machine as tomcat runs.

thanks in advance,

Bennet Xavier X
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

The easier way to share data between more than one application is to save it to a common store, such as a file or database. Would that do?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Bennet Xavier
Ranch Hand

Joined: Jun 19, 2008
Posts: 162
Yes, you are right. But some of the things i need to use frequently. so if i fetch from persistence its costly operation. i want to avoid that.

Then, I don't have the option for storing in persistence also.

Thats why i need to refer the Tomcat application for some values which are stored.

thanks,

Bennet Xavier X
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Ok. Well your only real solution for one JVM talking to another is RMI. A big hammer to crack a small nut I reckon, but if you can't use a file you don't really have any other options.

One thing I will say, you say going to a file or databate is a costly operation. This sounds like an early optimisation. Have you tested how costly iti s in the context of your application? RMI is not free either.
Bennet Xavier
Ranch Hand

Joined: Jun 19, 2008
Posts: 162
Thanks for your reply.

If its DB or file, i need to do I/O operation.

If its RMI at least i can reduce I/O operation, right.

I will use RMI itself for accessing the application.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

RMI is still I/O. It's just network I/O instead of disk I/O.

Actually, what it sounds like you need is Enterprise JavaBeans. However, Tomcat isn't an EJB container. But it's likely to be more trouble than it's worth to get an RMI server running in Tomcat, so what I'd recommend is that you look at a full JEE server like JBoss, WebSphere, WebLogic, or Oracle's OC4J. JBoss (and the JOnAS server from Objectweb) can use Tomcat (or jetty) as their servlet/jsp containers, but add the additional infrastructure to allow you to code your sharable resources as EJBs and access them from external applications. It's a lot faster and more reliable than re-inventing all that stuff yourself.


Customer surveys are for companies who didn't pay proper attention to begin with.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12823
    
    5
It sounds to me like you are worrying about a performance problem which has not been demonstrated to be important.

Google "premature optimization is the root of all evil" for an entertaining read.

Why not use one of the higher level mechanisms instead of RMI?

It would be easier to code and maintain - for instance - a REST style GET using HttpURLConnection to a servlet in Tomcat.

Bill
 
 
subject: Accessing Tomcat Memory in command line.