Thank you very much for your suggestions, Frank. That was really helpful.
From: Frank Zammetti [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: RE: How to read a large XML file in the ActionServlet
Date: Wed, 23 Jun 2004 14:30:27 -0400
I don't care how good of an XML parser you are using, parsing virtually any
XML file on a per-request basis is a Bad Idea (tm). You definitely want to
find a way to (a) store the parsed information in memory, or (b) maybe read
it from a database, which may or may not actually wind up being any better
depending on numerous factors.
I used to have to use a custom framework here at work before my glorious
leaders finally decided to listen to us architects an use Struts. This
framework used XML profile database, much like struts-config.xml. Early
on, this thing was reading this file for EVERY request, just to determine
which controller element to execute and where to forward to afterwards.
Apps built on this thing were just barely OK on killer hardware. Well, the
very first week I was using the thing, I rewrote the preprocessor that
parsed this file and instead read it in once at app startup and then read
the data in memory. True, there was no longer a way to do real-time
profile changes without downing the app, but all of a sudden our apps were
flying like nobody's business, and server load decreased for the same
number of concurrent users by a HUGE factor. Needless to say, people were
rather happy.
I can't stress the point enough: parsing XML per-request is almost never a
good idea. Making your myXmlClass class static (well, the result of the
XML parsing static anyway) is one way to go, and might be the best way,
performance-wise. Do the parsing from a Struts plug-in, store it in a
HashMap or whatever you need it to be in that class as a static member, and
your problem will probably go away.
Frank
From: manoj JC [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: How to read a large XML file in the ActionServlet
Date: Wed, 23 Jun 2004 14:15:08 -0400
Hi
I want to read a a large XML file for each request that comes to the
ActionServlet.
This is for a reporting application. What I did was I created seperate XML
file where I have specified the action elements and its related
subelements. So when I get the request I get the corresponding XML node
from the XML file for that action and based on its subelements I enter a
log into a database.
So I have my customized ActionServlet. And I am instantiating myXmlClass
in the process method. And I call a method called
myXmlClassObject.getXMLLogMessage() for each request (for each Action
class).
What is the recommended way to do this.
The problem that I am having is that the application freezes at the line
instantiate myXmlClass in the process method of my servlet.
Currently my code look like this
//MyActionServlet.java
init()
{
//perform initialization()
super.init()
}
process()
{
//do stuff
instantiate myXmlClass (which has a _saxparser.parse() method)
myXmlClassObject.getXMLLogMessage()//some database calls underneath it for
some logging
//do stuff
}
Should I make a static object of myXmlClass in my actionServlet.
Should I put myXmlClass into session, and check for each request whether
this object exists in session, if not create it.
Please help!!
_
Make the most of your family vacation with tips from the MSN Family Travel
Guide! http://dollar.msn.com
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
_
Watch the online reality show Mixed Messages with a friend and enter to win
a trip to NY
http://www.msnmessenger-download.click-url.com/go/onm00200497ave/direct/01/
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
_
Watch the online reality show Mixed Messages with a friend and enter to win
a trip to NY
http://www.msnmessenger-download.click-url.com/go/onm00200497ave/direct/01/
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]