• Post Reply Bookmark Topic Watch Topic
  • New Topic

I do not understand servlet initalization  RSS feed

 
Alan Smithee
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My jsp uses the tld to access this servlet:











Using weblogic9.0 as my container, I get an output of 0. I need it to be x. What am I doing wrong?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the servlet spec

The element content of this element must be an
integer indicating the order in which the servlet should be loaded. If the value is a
negative integer, or the element is not present, the container is free to load the servlet
whenever it chooses. If the value is a positive integer or 0, the container must load
and initialize the servlet as the application is deployed. The container must
guarantee that servlets marked with lower integers are loaded before servlets
marked with higher integers. The container may choose the order of loading of
servlets with the same load-on-startup value.



For some reason, you're using:
-2147483646
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, you're calling static methods from your servlet's class file from your tag. Why are you doing this?

Servlets are meant to respond to HTTP requests.
 
Alan Smithee
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:
Also, you're calling static methods from your servlet's class file from your tag. Why are you doing this?


Because I don't know any better and this code is being adapted from a JSP/JMS tutorial.

http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-jms.html

What I'm really trying to do is send a message from JSP to a JMS queue. This servlet misunderstanding is one symptom of my larger problem.

Anyway, thanks! I'll make the corrections and keep trying.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That article is pretty old and out of date.

These days, something like that would be put in a plain old java object that is initialized and bound to scope from a contextListener.

Even still, static methods are not going to be able to access member variables. This is the case whether the class is a servlet or not.
 
Alan Smithee
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:
That article is pretty old and out of date.

These days, something like that would be put in a plain old java object that is initialized and bound to scope from a contextListener.


Ah. I'll try to dig around for a better example then. Unless you know of something off hand?

Even still, static methods are not going to be able to access member variables. This is the case whether the class is a servlet or not.


That's something I should have known.


Thanks again!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!