Init method in servlet freezing the servlet

M

Mitch

I have already posted this query, although it was appended to one of my
threads with a different subject so if you have read this already I
apologise.

Rather than paste the whole thing over there is a link here to my
question
http://groups.google.com/group/comp.../fa1385d4fb472da7?tvc=1&#doc_2eb2277394b9a908

It pans out that I have a servlet which is calling an init method when
first invoked. However once the init method is called the servlet no
longer functions normally (It doesn't print like it is supposed to for
example) This means that I can not display within the System it
initialises any information about the system. I can't use a different
servlet either as this does not have permission to access the system.

I have found that this problem is also caused when the contents of the
init method are also used in the main methods of the servlet, however
they are best suited to the init method.

Here you can see that the init method is very simple

///////////////////////////////////
////////

public void init(ServletConfig config)
throws ServletException
{
super.init(config);

RSS = new RailSimulationSystem();

RSS.run();

}

////////////
//////////////////////////////////////

I wonder if it is because I am starting a thread?

the RSS object is initiated as I have the system println'ing to tell me
so.


Any ideas on what is going on which might cause this behaviour are
greatly appreciated.

Kind Regards,

Mitch.
 
T

Timo Stamm

Mitch said:
[...] once the init method is called the servlet no longer
functions normally [...]

public void init(ServletConfig config) throws ServletException {
super.init(config);
RSS = new RailSimulationSystem();
System.out.println("a");
RSS.run();
System.out.println("b");
}

I wonder if it is because I am starting a thread?

Are you sure you are starting a new thread? You have to either extend
Thread or implement Runnable and use new Thread(Runnable).

If the code above doesn't print "b" immediately after printing "a", you
are not starting a new thread.


Timo
 
M

Mitch

Timo said:
Mitch said:
[...] once the init method is called the servlet no longer functions
normally [...]

public void init(ServletConfig config) throws ServletException {
super.init(config);
RSS = new RailSimulationSystem();
System.out.println("a");
RSS.run();
System.out.println("b");
}

I wonder if it is because I am starting a thread?

Are you sure you are starting a new thread? You have to either extend
Thread or implement Runnable and use new Thread(Runnable).

If the code above doesn't print "b" immediately after printing "a", you
are not starting a new thread.


Timo

That is incredibly infuriating.

I am not printing b after I am printing a.
I am A) terribly grateful and B) ****ing furious. Sometimes you can't
see past the end of your nose. I am calling run on a Runnable object.
I should be making a new Thread and then Thread.starting it to make it
go. !"£$%^&*().

Thank you. I had println's and breakpoints everywhere but where I
needed them, right where I knew the problem was.

Well that solved it, thank you. I honestly don't know how long it would
have taken me, which is half of why I am so peeved.

Thank you very much!

Mitch.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top