Bear Bibeault wrote:What do you mean by "background classes"?
Bear Bibeault wrote:What's causing these classes to "run in the background"? We can't help you if you don't tell us what your code is doing.
Bear Bibeault wrote:Nothing runs at all unless it is made to. Perhaps you should read the Servlet Spec too understand how web apps operate, which is much different than standalone programs.
But the whole concept of "running in the background" is unnatural for web apps.
If your JSP needs a data construct to display, its controller should fetch that info from the DB or wherever it gets the data from and feed it to the page.
If you are a newcomer to web apps, I strongly suggest reading these articles:The Secret Life of JSPs The Front Man
The first explains what JSP is all about, the second how web apps should be constructed.
SeanMichael Hayes wrote:
Bear Bibeault wrote:What's causing these classes to "run in the background"? We can't help you if you don't tell us what your code is doing.
Right to be specific, my java classes read data off an xml file and create objects off of the data. These objects are then stored in an arrayList. What I want to do is list off these objects on a webpage. My jsp is pretty basic in that it reads the size of the object arrayList and creates tables for them.
However, no tables are created when I turn on the server and access it through my localhost. I reasoned that this may be because when the java program is running the arrayList has nothing in it initially and is populated as it runs and that the jsp only takes the initial value (zero) and thus creates NO tables at all. But what I want to know is....is the program running alongside the server and would it have populated arraylist?
Bear Bibeault wrote:Meantime, if you explain what the data is, and where it comes from, some concrete recommendations might be made.
Piyush Mangal wrote:
SeanMichael Hayes wrote:
Bear Bibeault wrote:What's causing these classes to "run in the background"? We can't help you if you don't tell us what your code is doing.
Right to be specific, my java classes read data off an xml file and create objects off of the data. These objects are then stored in an arrayList. What I want to do is list off these objects on a webpage. My jsp is pretty basic in that it reads the size of the object arrayList and creates tables for them.
However, no tables are created when I turn on the server and access it through my localhost. I reasoned that this may be because when the java program is running the arrayList has nothing in it initially and is populated as it runs and that the jsp only takes the initial value (zero) and thus creates NO tables at all. But what I want to know is....is the program running alongside the server and would it have populated arraylist?
Your background process and Web server will run in different JVMs so web application will not be able to see the data from background process. If you want to reuse the java classes , then deploy your class as a part of web app and have a ServletContextListener bootstraping this class.
Bear Bibeault wrote:I don't agree with that approach (separate threads in the web app).
I've done similar things before and I would keep the asynchronous polling in a separate Java daemon that writes the data into a database. The web app is simply a view onto that data and can fetch it from the DB whenever a user requests it from a browser.
SeanMichael Hayes wrote:So what your saying is that a database (like mySql?) is the way to go?
SeanMichael Hayes wrote:In its current form, my java project polls OIDs from several machines using SNMP. The OIDs polled for each machine is added into an Arraylist<String> in that machine's java object constructor. We then loop through that Arraylist and use a "get" method to poll the value of that OID. The value of which is appended to a string called "DeviceReading" with a ',' seperating the values . We then print it out into .csv file, the ',''s seperating the values into different columns in the file.
What I want to do is add a web tier, in which the values for each machine are printed out onto a web page hosted on a server. Obviously, I'm going into this kinda blind so any pointer would be appreciated.
There's a way to do it better - find it. -Edison. A better tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|