| how to determine when a servelt will unload???? |
|
 |
Index ‹ java-programmer
|
- Previous
- 3
- JList back colorHello, all !!!
Objective: I've got JList. I want the area inside it, where strings are
shown to be some color. But when I use myJList.setBackground(Color), the
whole list with outside part becomes repainted.
Help me plz.
- 3
- Can't reinstall Tomcat webapp because of log4j.properties lockedI've got a webapp that uses log4j for logging. The log4j.properties
file is in the classes directory of the application. Logging works
fine.
Problem is when I try to (using ANT) redeploy the application. This
first removes the application then installs a new jar.
It appears that Tomcat is unable to remove the log4j.properties file
because it is "in use". (The application has been stopped at this
point). So the new install fails until I manually restart tomcat at
which point the properties file can be deleted and all works fine.
Any ideas of how I can get Tomcat to "release" the properties file.
Is this a bug in log4j = not closing properties file after reading it?
- 4
- Blowfish hashDoes anyone know how to do a Blowfish hash in Java? I need
to hash a password
- 5
- Question about Naming ServiceHi everybody,
SITUATION. Two machines with JacORB: each runs a servant of mine.
PROBLEM. I need the two servants to share the same Corba NameServer so
that they can interact.
I tried to run the JacORB naming service on both machines but, at my
best, I get two separate corba "domains" (say, the two servants can't
see each other).
Any tips or documentation or demos about it?
I would appreciate anything, even if from other ORBs.
Thankyou.
- 6
- More newbie questions(newbie question thread consolidation thread)
Let me preface by saying I'm taking a java class, and my instructor likes to
see us maximize the usage of the collections framework whenever possible. He
wants an efficient oop design. I can get my code to run and do what I want,
but I'm not sure if I'm maximizing the usage of the collections framework,
and sometimes I make oop blunders. Hence my questions:
1) I have an ArrayList of Strings. I want to form a String that contains all
of the Strings, comma delimited. This is what I do. It works, but is there
are better or more correct way to do this?:
String returnValue = "";
for( String keyWord : _keywords )
returnValue = returnValue + keyWord + ", ";
// Strip off the last ", "
return returnValue.substring( 0, returnValue.length()-2 );
2) I have an ArrayList of Items, Item being a class with Strings and
ArrayLists or TreeSets of Strings. I need to search for and create a list of
items that have certain text in either the Strings, or the
ArrayList/TreeSets of Strings. I can do this, my code works, but again I'm
not sure I'm doing this most efficiently.
public class Item
{
private String _title1;
private String _title2;
private String _title3;
private TreeSet<String> list1 = new TreeSet<String>();
...
}
It was suggested I use a HashMap, but how would I implement that with the
above class, where I would have to search on different items in the class at
different times? My brute force code works, where I iterate through the list
with a for-each loop, checking each instance as I go through, but again may
not be the most efficient way.
- 6
- Render .eps in swingDoes anyone have any information on how i would go about rendering .eps
files in swing, whilst preserving the "vector/scalable" property of them?
best regards
Costas
- 7
- client/serverHi
How can I write a client server where the client download a file from the server?
Vincent
- 9
- Sun Commits to Open-Sourcing JavaOn 18 May 2006 10:59:02 -0700, Daeron wrote:
> Tues, May 16 2006 11:31 pm Erik Funkenbusch
>
>> Yes, I believe them. Just like they were going to make Java an ISO
> standard, and then changed their mind. After significant work was done
> by
> committee members.
>
> You mean like MS quiting OpenGL after significant work was done by
> committee members and why is this any different than MS keeping control
> of the Microsoft TCP protocols. And how does this sneering reference in
> any way invalidate currents statements Sun.
I wasn't aware that Microsoft controlled the OpenGL standard, and thus them
quitting it would put the work done by the members of the committee into
uselessness.
In other words, your argument is stupid.
- 9
- People Helping People!!!!!!!!!!!!People Helping Each Other
MAKE $250,000 IN WEEKS - 2007
AS SEEN ON OPRAH & 20/20
***Oprah Winfrey and ABC's investigative team 20/20 also can prove
it
can be done***
***Proven by various, highly- respected U.S. TV and radio programs
as
being 100% legal, feasible and true***
IF A 15 - YEAR OLD BOY COULD MAKE $71,000 IN JUST 5 WEEKS AND OTHER
$250,000 IN FEW MORE WEEKS - SO CAN YOU!!
THIS REALLY CAN MAKE YOU EASY MONEY!! IT WORKS!! BUT YOU HAVE TO
FOLLOW THE LETTER FOR IT TO WORK!!
THIS IS NOT A PYRAMID SCAM!!!
I came across an article similar to this that said you could make
thousands of dollars within Weeks with only an initial investment of
$12.00!
...HERE'S HOW!!
PayPal verifies that this $12 investment program is 100% legal and
is
a big hit this year see their note below or ask them directly...
For a simple investment of 15-30 minutes and just $12, it is 100%
worth it to make thousands so quickly.
This is not another scam that takes lots of your hard earned money;
this is a no risk investment that will make you thousands of dollars
very easily and quickly.
If you would like to take part in this opportunity or would like a
bit more information then please see the information below that was
kindly donated to me.
Thank you for using PayPal!"
Turn $12 into $30,000 in only 30 days...here's how! You have most
likely seen or heard about this project on TV programs such as 20/20
and Oprah or you may have read about it in the Wall Street Journal.
If not, here it is below - revealed to you in step-by-step detail.
This program is by no means new.
It has been in existence in many forms for at least a decade. In the
early days, it required a lot more time and effort, as well as an
investment of a few hundred dollars.
However, thanks to PayPal and the Internet, the investment is now
virtually ZERO!
And what's more, the entire process is FASTER, EASIER, and MORE
LUCRATIVE than it has EVER been!
I found this on a bulletin board and decided to try it: Make Money
with your PayPal account as shown on Oprah!
"A little while back, I was browsing through news groups and came
across an article similar to this that said you could make thousands
of dollars within weeks with only an initial investment of $12.00!
So I thought, "Yeah right, this must be a scam", but like most of
us,
I was curious, so I kept reading. Anyway, it said that you send only
$2.00 to each of the 6 email addresses stated in this article.
You then place your name and address at the bottom of the list at
the
# 6th position and email it to your friends as well as post this
message (with your email address in the list) to at least 200
newsgroups.
(There are hundreds of thousands)
No catch that was it.
So after thinking it over, and talking to a few people first, I
thought about trying it. I figured "what have I got to lose except
$12.00, right?"
So I invested the measly $12.00
Well GUESS WHAT!!
Within days, I started getting money coming into my Pay Pal account!
I was shocked!
I figured it would end soon, but the money just kept coming in. In
my
first week; I made about $50.00, which means that 25 people joined
the
group after they saw my posted messages. By the end of the second
week
I had made a total of over $1000.00!
In the third week I had over $10,000.00 and it's still growing. This
is now my fourth week and I have made a total of just over $42,000.00
and it's still coming in rapidly.
It's certainly worth $12.00, and the few minutes it took to join
PayPal.
I have spent more than that on the lottery!
Let me tell you how this works and most importantly, why it works.
Also, make sure you print a copy of this article NOW, so you can get
the information off of it, as you need it.
I promise you that if you follow the directions EXACTLY, that you
will start making more money than you thought possible by doing
something so easy!
SUGGESTION:
Read this entire message carefully!
Follow the simple directions and watch the money come in, it's that
easy! It's legal. And, your investment is only $12.00.
IMPORTANT: This is not a rip-off; it is not indecent; it is not
illegal; and it is virtually no risk-it really works! If all of the
following instructions are adhered to, you will receive extraordinary
dividends.
AGAIN, PLEASE NOTE:
Follow these directions EXACTLY, and $20,000 or more can be yours in
4 to 6 weeks. This program remains successful because of the honesty
and integrity of the participants.
Please continue its success by carefully adhering to the
instructions.
In this business your product is not solid and tangible, it's a
service.
You are in the business of developing Mailing Lists. Many large
corporations are happy to pay big bucks for quality lists. However,
the money made from the mailing lists is secondary to the income,
which is made from people like you and me asking to be included in
that list.
STEP 1:
Take a few minutes to join PayPal: www.paypal.com PayPal The
Internet's most trusted Internet banking system for your future
income. When creating your PayPal account make sure you use the same
Email address as your user name in the list below so people can send
money to your account.
STEP 2
Once you have a PayPal account running. Send $2.00 dollar donation
from your PayPal account to THE FIRST e-mail address on the list
along
with a note saying "Please add me to your list". Then use PayPal to
post $2 to EACH of the additional 5 Email Addresses below because you
pay people with an email address in PayPal.
To do this you may need to use a credit card, which is very easy,
and
secure so nobody but PayPal may see it.
If you don't have a credit card show this great lucrative offer to
someone that has one and get them to help you pay the $12.
What you are doing is creating a service.
This is absolutely legal!
You are requesting a legitimate service and you are paying for it!
Like most of us I was a little skeptical and a little worried about
the legal aspects of it all.
But I looked around and did some homework and found it was perfectly
legal.
Here are the 6 individual Email addresses that you have to send $2
to
through PayPal for this to work properly and for you to receive
money.
(If you don't send the money and decide to post the message with your
name in it anyway, PayPal will instantly pick this up and terminate
your account, immediately, besides the other penalties!!
If you did this you could get into serious trouble because it is
fraud. (So follow the instructions and post the $12 and you will make
lots of money with no hassles.)
Now send $2 to each of these following emails - addresses through
your PayPal account and pay $2 to each the following 6 email-
addresses.
These email addresses are PayPal IDs or usernames.
1.) email***@***.com
2.) kayciew...@yahoocom
3.) email***@***.com
4.) email***@***.com
5.) email***@***.com
6.) email***@***.com
STEP 3
Now... after paying $2.00 to each of the email placements above, take
the #1 Email Address off the list, move the other Email Addresses up
(6 becomes 5, 5 becomes 4, etc.) and add Your Email Address as number
6 on the list.
STEP 4
Change anything you need to, but try to keep this article as close to
the original as possible.
Now, post your amended article to at least 200 newsgroups (there are
thousands of groups).
And email your message to as many people you can. Remember, the more
you post and email the more money you make! This is perfectly legal!
IMPORTANT: This is not a rip-off; it is not indecent; it is not
illegal; and it is virtually no risk-it really works! If all of the
following instructions are adhered to, you will receive extraordinary
dividends.
PLEASE REMEMBER this program remains successful because of the
honesty
and integrity
of the participants and by their carefully adhering to the
directions.
You are simply paying into a money making chain of participants and
if the chain is broken you are screwing someone else out of their
fair
share.
So, as each person who joins the family and the directions are
followed, six members will be reimbursed for their participation as a
List Developer with two dollars each.
You then insert your Email Address into the list and it will move up
geometrically. So that when your name reaches the #1 position you
will
have potentially received thousands of dollars into your account!!!
What an opportunity for only a total of $12.00!!
$2 for each of the first six people listed above.
To begin with, please send you're joining fee now (which is $2.00 to
each email address listed above) then add your own Email Address to
the list and you're in business!
HOW TO POST TO NEWS GROUPS:
Use Netscape or Internet Explorer and try searching for various
newsgroups (on-line forums, message boards, chat sites, discussions.)
Log on any search engine like yahoo.com, google.com, altavista.com,
excite.com, etc., then search with the subject ''millionaire message
board'' or ''money making message board'' or ''employment message
board'' or ''money making discussions'' or ''money making forum'' or
''business message board'' etc.
You will find thousands and thousands of message boards. Click on
them
one by one and you will find the option 'post a new message'. Then
Post this article as a 'new message' by highlighting the text of this
letter and selecting copy then paste from the edit menu.
Fill in the Subject, this will be the header that everyone sees as
they scroll through the list of postings in a particular group, click
the post message button.
You're done with your first one! It only takes about 60 seconds to
complete postings on message boards after you catch on.
REMEMBER, THE MORE NEWSGROUPS YOU POST IN, THE MORE MONEY YOU WILL
MAKE!!
BUT YOU HAVE TO POST A MINIMUM OF 200!
That is it!!
You will begin receiving money in your account from around the world
within days!
JUST MAKE SURE ALL THE ADDRESSES ARE CORRECT
Now the WHY part out of 200 postings:
Say I receive only 5 replies (a very low example). So then I made
$10.00 with my name at #6 on the letter. Each of the 5 persons who
just sent me $2.00 make the MINIMUM 200 postings, each with my name
at
# 5 and only 5 persons respond to each of the original 5, this is an
additional $50.00 for me. Now those 24 each make 200 minimum posts
with my name at #4 and only 5 replies each.
This brings in an additional $250.00. Those 125 persons turn around
and post the MINIMUM 200 with my name at #3 and receive 5 replies
each, I will make an additional $1,250.00. Ok, now here is the FUN
part, each of those 625 people post a MINIMUM of 200 letters with my
name at #2 and they receive 5 replies each. That just made me
$6,250.00!!!
Those 3125 persons will all deliver this message to 200 newsgroups
with my name at #1 and if still 5 persons per 200 react, I will
receive an additional $31,250.00!!
With an investment of only $12.00!!
A - M - A - Z - I - N - G - !!
When your name is no longer on the list, you just take the latest
posting in the newsgroups, and send out another $12.00 to Email
Addresses using PayPal on the list, putting your name at number 6
again.
And start posting again.
The thing to remember is that thousands of people all over the world
are joining the Internet and reading these articles every day.
JUST LIKE YOU ARE NOW!!
This works year round, but the holidays are coming up. Would'nt you
want to get what you want for christmas? Your children or even give
to
charities? Grand Opportunity!
So, can you afford $12.00 to see if it really works?? I think so!
People have said, "what if the plan is played out and no one sends
you
the money? So what!
What are the chances of that happening when there are tons of new
honest users and new honest people who are joining the Internet and
newsgroups everyday and are willing to give it a try.
Remember what goes around comes around, if you don't make the initial
$12 investment you won't receive any of the benefit.
- 12
- Repainting and threading - the eternal problem...Hi there folks!
I have a program, with MANY lines of code, so I will not post the
entire program here. However, this is my problem.
I have a GUI program based on swing which contains a JList:
===
this.userTrapList = new JList(this.userTrapListModel);
this.userTrapList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
this.userTrapList.setLayoutOrientation(JList.VERTICAL);
this.userTrapList.addMouseListener(this);
this.userTrapList.setCellRenderer(new MyCellRenderer());
===
As you can see, I also have a custom cell render called
MyCellRenderer:
===
private class MyCellRenderer extends DefaultListCellRenderer {
public static final long serialVersionUID = 1L;
public Component getListCellRendererComponent(JList list, Object
value,
int index, boolean isSelected, boolean cellHasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list,
value, index, isSelected, cellHasFocus);
TSListObject tsl = null;
try {
tsl = (TSListObject)value;
} catch (ClassCastException cce) { }
if (tsl != null && tsl.hasBeenSent()) {
// if tsl has been sent, set background.
label.setBackground(hasBeenSentColor);
}
//// HERE I LEFT SOME CODE OUT ////
return label;
}
}
===
One of the features of the cell renderer is that, once a TSListObject
(which is what the JList contains) flag "hasBeenSend" is true, the
background color is set to green.
What the program does it iterates over the items of the list and sends
them. The class which sends them implements runnable, and here is how
I send them:
===
Enumeration<TSListObject> en = this.userTrapListModel.elements();
while (en.hasMoreElements()) {
TSListObject tmpTSL = en.nextElement();
/* THIS IS WHERE THE SENDING HAPPENS! */
SnmpPDU pdu = tmpTSL.getSnmpPDU();
TrapSenderModel ts = new TrapSenderModel(pdu, session,
dstHost.getText(), spinnerInt.intValue(), new Debug(1));
ts.addObserver(this);
Thread tsThread = new Thread(ts);
tsl.setHasBeenSent(true);
tsThread.start();
try {
tsThread.join();
Thread.sleep(500);
} catch(InterruptedException ie) {
//Catch nothing
}
}
===
As you can see, the actual sending happens when TrapSenderModel's
method run() is executed, which is the same as tsThread.start();
The TrapSenderModel extends Observable and every time it does
send(pdu) (which is not displayed here), it setChanged() and
notifyObservers(pdu).
In my GUI program, which implements Observer, I have an update()
method:
===
public void update(Observable obs, Object obj) {
System.out.println("Update caught!");
this.userTrapList.repaint();
}
===
Okey... Now that we've got the background covered, lets get down to
the problem:
If my JList contains 9 items, and I send them all, the output to
System.out is a nice print of "Update Caught" every 500 milliseconds,
HOWEVER, the background color of the labels do not update until all
items have been sent.
I would like the background of each cell to change momentaneously, as,
if we have a 0.5 second wait between sending every item, and we send
100 items, that means 50 seconds of not showing any change. This will
probably make the user impatient or worried.
I haev tried several methods to get this working, however, I did never
become best friends with SwingWorker and such....
I'm just thinking that, since the sending happens in a thread of its
own, why cannot the GUI update in its own native thread?
What have I missed? I've spent the entire day here and havn't come up
with anything!
I'm greatful for any help I can get (and yes, I've read manuals,
articles, forums, google and so on).
Yours,
Jonas
- 12
- Strange servlet exceptionOn Feb 1, 7:35 am, CarloC <email***@***.com> wrote:
> Hi,
> inside my generic servlet I get this error when I call this method:
> 'session.getAttribute' command (line 36):
>
> java.lang.NullPointerException
> at java.util.Hashtable.get(Hashtable.java:336)
> at
> org.apache.catalina.session.StandardSession.getAttribute(StandardSession.java:
> 1024)
> at
> org.apache.catalina.session.StandardSessionFacade.getAttribute(StandardSessionFacade.java:
> 110)
> at workcity.servlet.GenericServlet.checkToken(GenericServlet.java:36)
>
> This is the java code:
>
> HttpSession session = req.getSession();
> ArcUtente vo = (ArcUtente) session.getAttribute(token);
>
> req is a HttpServletRequest object !=null and
> token is a String object != null.
>
> You can help my?
> Carlo
Looking at the JavaDoc for Hastable:
* @throws NullPointerException if the specified key is null
It very well could be token really is null.
Just to verify, try this:
HttpSession session = req.getSession();
if (token == null) { throw new NullPointerException("Token really IS
null!") };
ArcUtente vo = (ArcUtente) session.getAttribute(token);
- 13
- Returning A ResultSetI tried breaking out this chunk of code into a function so that I can
reuse it without having to have these huge try/catch blocks repeated
if I do multiple SQL queries.
So my problem is that the 'return' doesn't run in my first try block
because I have a finally block which supersedes returning anything.
However I can't return in the finally block because either a)it
returns and never closes the stmt and conn, or b)I have nothing to
return because stmt has always been closed.
Does anyone have any ideas how to return this ResultSet and still be
able to close it?
Possible ideas, but don't think they'll work:
1)Is there a way to pass by reference so that I can give this function
a ResultSet to pass the results to so I never have to return it?
2)If I locally make a ResultSet, and never perform .close() on it,
will it be deallocated on it's own since it's a local variable?
3)If this function was static, so that every time it ran, it would set
the same variable to the new results when it returns, would that stop
multiple ResultSets from not being closed?
/
************************************************************************/
public ResultSet sqlQuery(String sql)
{
Connection conn = null;
Statement stmt = null;
try
{
conn = RDBMServices.getConnection ();
stmt = conn.createStatement();
return stmt.executeQuery(sql);
}
catch (SQLException ex)
{
System.out.println("SQL Error 1: "+ex);
}
finally
{
try
{
if (stmt != null) stmt.close();
if (conn!= null)
{
RDBMServices.releaseConnection(conn);
}
}
catch (SQLException e) {}
}
}
/
************************************************************************/
- 15
- jndi setup of ldaphi,
I'm trying to load a Postgresql Jdbc3PooledConnection object into my
openldap server on a redhat box :).
what I wanted was a context jdbc/database, and in that a series of
driver references. I have made an entry, but am not sure I've dont it
right though. Can you see what is wrong?
The examples in the web all have lookups of the form
lookup(jdbc/EmployeeDB)
yet mine won't work unless i use ldap like tags as in
lookup("cn=database,cn=jdbc");
firstly i set up jndi properties to connect to the ldap server. (had
to add write permission on redhat box)
<code>
java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory
java.naming.provider.url=ldap://192.168.1.1:389/dc=mtel,dc=co.uk
</code
Then I added the references (had to do this one at a time, modifying
code
lines to add context, then the driver). This i checked with
slapsearch, and
made sure the entries where there. I loaded the driver in a new test
program to make a connection from the driver to test it, so i know it
works.
<code>
Hashtable env = new Hashtable();
Context ctx = new InitialContext();
InitialDirContext dctx = new InitialDirContext();
if(ctx == null )
throw new Exception("JNDI could not create InitalContext
");
//dctx.createSubcontext("cn=jdbc"); ** context 1
//dctx.createSubcontext("cn=database,cn=jdbc"); ** context 2
Jdbc3PoolingDataSource src = new Jdbc3PoolingDataSource(); //
driver
src.setDataSourceName("livedb");
src.setServerName("192.168.254.99");
src.setDatabaseName("livedb");
src.setUser("user1");
src.setPassword("youwish");
src.setMaxConnections(10);
ctx.bind("cn=livetest,cn=database,cn=jdbc", src);
</code>
- 15
- HashSet with complicated objects (fin!)On Sat, 20 Nov 2004 03:34:26 +0000, Tony Morris wrote:
> "Mike" <email***@***.com> wrote in message
> news:email***@***.com...
>> Hey!
>> [dumb question was here]
>> Many thanks.
>>
>> Regards,
>>
>> Mike
>
> The fact that you are talking about a HashSet implies that you aren't doing
> things the right way.
> Specifically, you should be handling types with an interface reference, such
> as a java.util.Set.
>
Yes, sorry, sloppy language. I hate it when I do that. The Set is
declared as a Set but instantiated as a HashSet, as you have shown below.
> Here is an example:
> Set<?> s = new HashSet<?>();
>
> So now you are talking about a Set - the underlying implementation being
> [... now-obvious-seeming explanation deleted for brevity ...]
> that you meet that contract or the consequences are dire (and often
> under-estimate).
>
(sound of penny, probably dislodged by whacking side of head with palm
of hand, dropping into the mechanism)
Yah, gotcha! D'oh.
> Here are some links of interest:
> [useful links elided]
Excellent, thank you!
Thanks also to Bill Brogden for the whack the other way.
Regards,
Mike
- 15
- enum: display elements of an enum specified at runtimeHello,
I have the following problem:
I need to perform validation on an input parameter that is a String.
This String has to be one of the values of an enumeration.
The problem is that the enumeration type is not known until runtime - thus
the caller tells me that the concerned enum by specifying its full
qualified name.
e.g.
boolean validateStringOnEnum( String toTest, String
enumFullQualName);
Does anybody know what the code would look like?
Cheers!
|
| Author |
Message |
efiedler

|
Posted: 2003-7-9 1:58:00 |
Top |
java-programmer, how to determine when a servelt will unload????
Hi -
I have a webpage that utilizes a servlet (written in JBuilder 7 and is
ran under Tomcat 4.0)...is there a way to find out how long of an idle
time is allowed (no calls to the servlet from the client) before the
servlet will be unloaded by Tomcat? And if I can find this out, can I
set this value somehow.
I have tried using the session.setmaxintervaltime but that does not
seem to work.
I would like to be able to kill the servlet after some set amount of
time so that I can run some code in the servelts destory method.
Thanks
|
| |
|
| |
 |
Ben_

|
Posted: 2003-7-9 3:49:00 |
Top |
java-programmer >> how to determine when a servelt will unload????
> I have a webpage that utilizes a servlet (written in JBuilder 7 and is
> ran under Tomcat 4.0)...is there a way to find out how long of an idle
> time is allowed (no calls to the servlet from the client) before the
> servlet will be unloaded by Tomcat? And if I can find this out, can I
> set this value somehow.
It's implementation dependent, see the Servlet Specification:
SRV.2.3.4 End of Service
The servlet container is not required to keep a servlet loaded for any
particular
period of time. A servlet instance may be kept active in a servlet container
for a
period of milliseconds, for the lifetime of the servlet container (which
could be a
number of days, months, or years), or any amount of time in between.
When the servlet container determines that a servlet should be removed from
service, it calls the destroy method of the Servlet interface to allow the
servlet to
release any resources it is using and save any persistent state. For
example, the
container may do this when it wants to conserve memory resources, or when it
is
being shut down.
Before the servlet container calls the destroy method, it must allow any
threads that are currently running in the service method of the servlet to
complete
execution, or exceed a server-defined time limit.
Once the destroy method is called on a servlet instance, the container may
not route other requests to that instance of the servlet. If the container
needs to
enable the servlet again, it must do so with a new instance of the servlet's
class.
After the destroy method completes, the servlet container must release the
servlet instance so that it is eligible for garbage collection.
> I have tried using the session.setmaxintervaltime but that does not
> seem to work.
Do not confuse Servlet life-cycle with session life-cycle.
> I would like to be able to kill the servlet after some set amount of
> time so that I can run some code in the servelts destory method.
What for ?
|
| |
|
| |
 |
John C. Bollinger

|
Posted: 2003-7-9 5:12:00 |
Top |
java-programmer >> how to determine when a servelt will unload????
efiedler wrote:
> I would like to be able to kill the servlet after some set amount of
> time so that I can run some code in the servelts destory method.
Then you are using the wrong tool for the job. If you explain the
bigger picture of what you want to accomplish then perhaps we can
suggest some alternatives.
John Bollinger
email***@***.com
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Forcing swing gui to be drawnHey, right now I have a program that analyzes an EKG when a button is
clicked. I want to pop up a progress bar in a new frame to show how far
it is, but I'm having problems. I can create the frame, and it will
appear, but it won't draw the progress bar until it is done executing
all of the other commands.
I ahve tried opening the frame with a separate thread, but it resulted
in the same problem. I guess there must be some draw queue that is on a
low priority, but I really have no idea why it isn't working.
Any help would be great... I show this at a science fair in 2 days.
Thanks!
-Thomas
- 2
- How to render a JCheckBox on cells of JList?I do it like this:
public class CheckBoxCellRenderer extends JCheckBox implements
ListCellRenderer {
public CheckBoxCellRenderer() {
super();
}
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
if(isSelected)
{
this.setForeground(java.awt.Color.BLUE);
}
this.setEnabled(isSelected);
this.setText("Hello");
return this;
}
However, there is a problem: I can not select or disselect those check box
rendered in the JList.
What wrong?
Thanks.
MaoXuePeng.
- 3
- URL in IFRAMELet's say I have a struts action at http://xyz.com/someAction.do and this
URL is referred from one IFRAME via "src" attribute of IFRAME. Is it
possible for me to detect inside someAction.do which page is embedding it in
an IFRAME? How can I do this?
et me put question in a different way, if I refer to Google API with this -
code:
------------------------------------------------------------------------------
<script
src="http://maps.google.com/maps?file=api&v=2.x&key=ABQIAAAAHuQre3TX-ZKoHs97iqelnBQn09xNixTqt4LnUZ12n-xJURxIHRRdLvNa4xtUwCJO0gkyTjCSRjfctQ"
type="text/javascript">
------------------------------------------------------------------------------
How does it know that the request is coming from domain xyz.com? It is not
purely based on the key - if I send same key from another domain, it doesn't
work! So how can I do that? Which header do I use? The referer header is
returned as null!
- manish
- 4
- hot java"hot java" sounds so...pornographic? larcenous?
anyhow, suns "hot java browser" is end-of-life, or whatever. I've poked
around a bit and found jazilla, some sort of "ice" java..
anyone use these, or other browsers written in java?
- 5
- Hibernate305: delete query fails with "must begin with SELECT or FROM"I'm using Hibernate 3.0.5, JDK 1.4.2, and Oracle 9i.
I'm following the Hibernate 3.0.5 docs to build a query to delete rows
from a table. My code looks something like this:
-----------------
String hql = "delete ReqField " +
"where fieldName = :fieldName and value
= :value";
Query query =
sessionFactory.getCurrentSession().createQuery(hql);
query.setString("fieldName", fieldName);
query.setString("value", value);
int deletedRows = query.executeUpdate();
-----------------
This fails with:
org.hibernate.QueryException: query must begin with SELECT or FROM:
delete [delete ReqField where fieldName = :fieldName and value
= :value]
What is wrong with my query?
- 6
- JTree sorting ...Is there a simple way to sort tree nodes either by the JTree or its model ?
I can't seem to find anything on the subject.
Thank you in advance,
Benoit
- 7
- java 6 used in large companies?hi..
we are a large company considering the move from java 1.4 to either 5
or 6.
at the same we are upgrading to was6 (or maybe jboss 4), we are
interested to learn if there are any major projects on enterprise
level involving java 6 (including the use of it's web services
framework).
- 8
- Bound Threads (Re: Process vs Thread: what are the consequences?)On Tue, 13 Nov 2007 16:04:12 +0000, Kenneth P. Turvey wrote:
> Just based on some experimentation I was doing, this doesn't seem to be
> true. I'm running Linux with the Sun JVM, and it didn't map each Java
> thread to a native thread until the Java thread was spending enough time
> executing. I was actually trying to get this mapping (1 to 1) and found
> it impossible to guarantee under Linux with the Sun JVM.
>
> Under Solaris there is the -XX:UseBoundThreads (or something similar) to
> get that behavior, but under Linux no such option exists.
>
> I will freely admit that my experiment could have been flawed, but it
> wasn't behaving as if it was using more than a single native thread. I
> suspect that the article above is out of date.
I hate to followup my own post, but I've been looking at this problem
again and I'm really just unhappy with how it works. Since this can so
easily be solved under Solaris, and Lew (I think?) mentioned that this is
all JVM dependent. I was hoping somebody could point me to a JVM that
runs under Linux that supports the -XX:UseBoundThreads option or something
similar. I want a 1:1 mapping between native threads and Java threads and
I just can't seem to get it.
Does anyone have any idea? (BTW, I checked IBM's JVM).
--
Kenneth P. Turvey <email***@***.com>
- 9
- OutOfMemory and Swap SpaceI have this strange issue with an Out Of Memory error thrown on a Sun
JVM 1.4.1 residing on a Windows 2000 box.
The Windows boxes is configured to have 4 GB physical RAM out of which
2 GB is available to applications on their server. ( Based on this
article at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/4gt_ram_tuning.asp
)
Out of this 2 GB , we have 3 JVMs of heap size at 768 M. Thich means a
total of 2034 Megs allocated only to Java processes implying a 2048 -
2034 = 14 Megs left for other applications and most importantly swap
space.
I have -verbose:gc logs that tell me that initially a couple of full
GCs happen followed by a monotonically increasing scavenges and just
before the OOM some hectic full GCs happen apparently to reclaim some
memory but never do.
How important is the consideration of Swap Space in troubleshooting
such an error. Since this is a production environment, I just wanted to
have an idea before I go ahead and recommend a decrease in the heap
sizes for this environment.
Your assitance is greatly appreciated.
-Paddy
- 10
- put application on server ??!!!!I have developed a java application that can return shortest path by
inputting data.
I would like to integrate this application into web application by putting
into tomcat server so that client can use the application through the
internet.
I am new to web service programming and I just start to learn jsp. I would
like to ask how I can do such implementation?
make my application into a bean ? and use the bean?
Please give me advice and help or references ..
Thousands thanx
- 11
- Response cache on the application serverIs it a good thing to cache the search result?
The metadata for our system can be as much as 100,000
I am trying to enable the response cache on the web server.
However, I am thinking about the problem i might meet.
When you cache the search result, is it possible the other
person throw the same condiiton and see the same result?
With our system there some security set for each row, so
if this happens there is a security leak.
MD
- 12
- Error passing Element to web serviceI'm upgrading from WebLogic 6.1 to WebLogic 8.1 SP 4.
We used to specify weblogic.soap.http.SoapInitialContextFactory and
weblogic.soap.encoding.factory to lookup the web service in the client.
Well, the SoapInitialContextFactory and CodecFactory classes are no
longer around. So now I've used clientgen to generate the stubs and
here is my client code:
MyWebService service = new MyWebService_Impl(wsdlurl);
MyWebServicePort port = service.getMyWebServicePort();
Element result = port.processIt(theElement);
However, I get the following error calling processIt:
java.rmi.RemoteException: web service invoke failed:
javax.xml.soap.SOAPException: failed to serialize interface
org.w3c.dom.Element weblogic.xml.schema.binding.SerializationException:
Failed to serialize Document due to the following error
weblogic.xml.stream.XMLStreamException: The local name of an attribute
cannot be null
...
Caused by: weblogic.xml.schema.binding.SerializationException: Failed
to serialize Document due to the following error
weblogic.xml.stream.XMLStreamException: The local name of an attribute
cannot be null
at
weblogic.xml.schema.binding.internal.builtin.DocumentCodec.serialize(DocumentCodec.java:76)
...
Here's the schema and xml file:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://myproject.org/myproject_test.xsd"
xmlns:myproject_test="http://myproject.org/myproject_test.xsd"
elementFormDefault="qualified">
<element name="TEST">
<complexType>
<sequence>
<element ref="TEST_ID"/>
</sequence>
</complexType>
</element>
</complexType>
<element name="TEST_ID" type="string"/>
</schema>
<?xml version="1.0" encoding="UTF-8"?>
<TEST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://myproject_test.xsd"
xsi:schemaLocation="http://myproject.org/myproject_test.xsd"
file:///N:/myproject/metadata/myproject_test.xsd">
<TEST_ID>ABCD1234</TEST_ID>
</TEST>
I've been testing with this bare minimum schema so that I can change
the namespaces and other things easily. The one and only thing that's
made a difference is when I take out the namespace stuff from the xml
file, it does get sent to the server. I.E.:
<?xml version="1.0" encoding="UTF-8"?>
<TEST>
<TEST_ID>ABCD1234</TEST_ID>
</TEST>
However, I can't leave it like that because the server doesn't know
what to do with it. Also, when the server tries to send the response,
it gets the same error as above.
weblogic.xml.stream.XMLStreamException: The local name of an attribute
cannot be null
at
weblogic.xml.babel.adapters.DOMAdapter.adaptAttribute(DOMAdapter.java:113)
at
weblogic.xml.babel.adapters.DOMAdapter.adaptElement(DOMAdapter.java:147)
...
javax.xml.soap.SOAPException: failed to serialize interface
org.w3c.dom.Element weblogic.xml.schema.binding.SerializationException:
Failed to serialize Document due to the following error
weblogic.xml.stream.XMLStreamException: The local name of an attribute
cannot be null
The web service also returns an Element, but it's a different type from
a different schema, which I haven't touched. So the server is having
the same problem as the client.
If I change the web service to receive and return only strings, it
works fine. But I haven't been able to figure out why it won't work
for the Element. Does this sound like a problem with my WebLogic
configuration, the schemas/xml files, the web service, the client? Is
there a way to tell what attribute it is complaining about?
Thanks,
Christy
- 13
- Java Native Interface - passing parameter array of different datatypesGreets!
Yesterday I googled for hours to find a tutorial how to call Java
methods from C++ native code. Unfortunately I didn't find anything
useful, the Java JNI documentation doesn't capture the functionality
of the JNI very well.
I want to do the following: I want to call a Java method from C++
code. The Java method has some parameters of different datatypes, like
public static boolean dosomething(int x, long y, String z)
for example. Is there any way to do this? The Call...Methods() take
the method ID and an array of parameters to pass to the function, but:
HOW TO CREATE AN ARRAY OF DIFFERENT DATATYPES???
It's only possible to create a new array calling something like
NewObjectArray() when passing a datatype given.... I think, the only
way to pass parameters of different datatypes from C++ to Java methods
is to create a new class containing all parameters necessary and to
pass the class as the one and only argument.
Any ideas?
Best Regards
Clemens
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
- 14
- Java Chat Recording.Hi,
A website I use has a chat room and it's chatter-side interface is a Java
application. The comments chatters post come thick and fast and, although
there is a scoll bar, it's no good scrolling down to see comments missed,
as, as soon as a new comment is posted, all the comments scroll up to it.
There is no cut-and-paste/recording facility. As it's possible to scroll
up and down the comments, there must be somewhere where the comments are
held. Would this be just in some sort of video buffer, a
constantly-appended file on my PC's disk drive or just in memory? Is there
any way to record the conversations? Have the output from the Java
application redirected to a file, etc?
Thanks in advance.
Yours,
Gary Hayward.
- 15
- Parsing a test fileI'm pretty new to Java and have been assigned to parse a log file.
The file is tab delimited. I have several tokens that I need to look
for. I have to find all the rows that have "290" then check a column
within that row. That value must match a pattern. The pattern will be
stored in a db table, so the user can add muliple patterns. That item
will then be placed in a new file.
A good example would be awesome.
Thanks.
|
|
|