Obtaining object initialized in contextlistener in non servlet-object

Hi, I don't know if this is the correct forum so I'll give it a try.
I'm currently developing an n-tier webapp. At initialisation I would like to initialize a ConnectionPool object I made and put it into a session object at context initialization in a ServletContextListener class. The ServletContextListener class is initialised directly at the startup of Tomcat or other JSP engine. I would like to do this so when I need the connectionpool object I don't have to create it again, but instead get it from the session. Has anyone done this already or is there a better, cleaner way to access such an object? Best way would be to not put it in a session but making it globally accessible once it isneeded. Can anyone help me with this?
Hope someone can help. Thanks. Michiel.

But I was wondering if by implementing it as
a singleton, how does the JVM know that there is
already an instance available once there is?If you implement the singleton correctly you will have one instance per classloader. Since all your classes will likely have the same classloader when you call getInstance you will retrieve the same singleton instance.
If Ido implement it in Tomcat, how will then get a
connection in an object wihtout passing it though a
JSP/servlet?You construct an initial context and do a naming lookup. There are examples in the link I posted.

Similar Messages

  • Non servlet to use resource

    Hi all,
    is it possible for non-servlet classes (located in WEB-INF/classes) to load/use resource of web application just as Servlet doing with getServletContext().getResource() ?
    I am using Tomcat 6.
    Any hought would be really appreciated.
    thanks

    It is better to use the Class.getResourceAsStream method or the ResourceBundle.getBundle methods to locate resources in the classpath. You could pass the servletContext object to the other classes but this violates the separation between presentation and business logic and should be avoided.

  • Non-servlet class in servlet program

    hi,
    I declare a non-servlet class which is defined by myself in a servlet class. I passed the complie but got an runtime error said NoClassDefFoundError. Does anyone can help me? Thanks.
    The following is my code.
    //get the search string from web form
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.net.*;
    import java.util.*;
    public class SearchEngines extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {   
    String searchString = (String) request.getParameter("searchString");
         String searchType = (String) request.getParameter("searchType");
         Date date = new java.util.Date();
         response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    Vector doc_retrieved = new Vector();
    BooleanSearch bs = new BooleanSearch();
    doc_retrieved=bs.beginSearch(searchString, searchType);
    out.println("<HTML><HEAD><TITLE>Hello Client!</TITLE>" +
                   "</HEAD><BODY>Hello Client! " + doc_retrieved.size() + " documents have been found.</BODY></HTML>");
    out.close();
    response.sendError(response.SC_NOT_FOUND,
    "No recognized search engine specified.");
    public void doPost(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    doGet(request, response);
    // a search engine implements the boolean search
    import java.io.*;
    import java.util.*;
    import au.com.pharos.gdbm.GdbmFile;
    import au.com.pharos.gdbm.GdbmException;
    import au.com.pharos.packing.StringPacking;
    import IRUtilities.Porter;
    public class BooleanSearch{
         BooleanSearch(){;}
         public Vector beginSearch(String searchString, String searchType){
              Vector query_vector = queryVector(searchString);
              Vector doc_retrieved = new Vector();
              if (searchType.equals("AND"))
                   doc_retrieved = andSearch(query_vector);
              else
                   doc_retrieved = orSearch(query_vector);
              return doc_retrieved;
         private Vector queryVector(String query){
         Vector query_vector = new Vector();
              try{
                   GdbmFile dbTerm = new GdbmFile("Term.gdbm", GdbmFile.READER);
              dbTerm.setKeyPacking(new StringPacking());
              dbTerm.setValuePacking(new StringPacking());
              query = query.toLowerCase();
              StringTokenizer st = new StringTokenizer(query);
              String word = "";
              String term_id = "";
              while (st.hasMoreTokens()){
                   word = st.nextToken();
                   if (!search(word)){
                        word = Stemming(word);
                        if (dbTerm.exists(word)){
                   //          System.out.println(word);
                             term_id = (String) dbTerm.fetch(word);
                             query_vector.add(term_id);
              catch(GdbmException e){
                   System.out.println(e.getMessage());
              return query_vector;
         private Vector orSearch(Vector query_vector){
              Vector doc_retrieved = new Vector();
              try{
                   GdbmFile dbVector = new GdbmFile("Vector.gdbm", GdbmFile.READER);
                   dbVector.setKeyPacking(new StringPacking());
                   dbVector.setValuePacking(new StringPacking());
                   int doc_num = dbVector.size();
                   String doc_id = "";
                   String temp = "";
                   for (int i = 1; i <= doc_num; i++){
                        boolean found = false;
                        doc_id = String.valueOf(i);
                        temp = (String) dbVector.fetch(doc_id);
                        StringTokenizer st = new StringTokenizer(temp);
                        while (st.hasMoreTokens() && !found){
                             temp = st.nextToken();
                             StringTokenizer st1 = new StringTokenizer(temp, ",");
                             String term = st1.nextToken();
                             if (query_vector.contains(term)){
                                  doc_retrieved.add(doc_id);
                                  found = true;
              catch(GdbmException e){
                   System.out.println(e.getMessage());
              return doc_retrieved;
         private Vector andSearch(Vector query_vector){
              Vector doc_retrieved = new Vector();
              try{
                   GdbmFile dbVector = new GdbmFile("Vector.gdbm", GdbmFile.READER);
                   dbVector.setKeyPacking(new StringPacking());
                   dbVector.setValuePacking(new StringPacking());
                   int doc_num = dbVector.size();
                   String doc_id = "";
                   String temp = "";
                   for (int i = 1; i <= doc_num; i++){
                        Vector doc_vector = new Vector();
                        boolean found = true;
                        doc_id = String.valueOf(i);
                        temp = (String) dbVector.fetch(doc_id);
                        StringTokenizer st = new StringTokenizer(temp);
                        while (st.hasMoreTokens()){
                             temp = st.nextToken();
                             StringTokenizer st1 = new StringTokenizer(temp, ",");
                             String term = st1.nextToken();
                             doc_vector.add(term);
                        for (int j = 0; j < query_vector.size(); j++){
                             temp = (String) query_vector.get(j);
                             if (doc_vector.contains(temp))
                                  found = found & true;
                             else
                                  found = false;
                        if (found)
                             doc_retrieved.add(doc_id);
              catch(GdbmException e){
                   System.out.println(e.getMessage());
              return doc_retrieved;
         private String Stemming(String str){
              Porter st = new Porter ();
              str = st.stripAffixes(str);
              return str;          
         private boolean search(String str){
              //stop word list
              String [] stoplist ={"a","about","above","according","across","actually","adj","after","afterwards","again",
                                       "against","all","almost","alone","along","already","also","although","always","am","among",
                                       "amongst","an","and","another","any","anyhow","anyone","anything","anywhere","are",
                                       "aren't","around","as","at","away","be","became","because","become","becomes","becoming",
                                       "been","before","beforehand","begin","beginning","behind","being","below","beside",
                                       "besides","between","beyond","billion","both","but","by","can","cannot","can't",
                                       "caption","co","co.","could","couldn't","did","didn't","do","does","doesn't","don't",
                                       "down","during","each","eg","eight","eighty","either","else","elsewhere","end","ending",
                                       "enough","etc","even","ever","every","everyone","everything","everywhere","except",
                                       "few","fifty","first","five","for","former","formerly","forty","found","four","from",
                                       "further","had","has","hasn't","have","haven't","he","he'd","he'll","hence","her","here",
                                       "hereafter","hereby","herein","here's","hereupon","hers","he's","him","himself","his",
                                       "how","however","hundred","i'd","ie","if","i'll","i'm","in","inc.","indeed","instead",
                                       "into","is","isn't","it","its","it's","itself","i've","last","later","latter","latterly",
                                       "least","less","let","let's","like","likely","ltd","made","make","makes","many","maybe",
                                       "me","meantime","meanwhile","might","million","miss","more","moreover","most","mostly",
                                       "mr","mrs","much","must","my","myself","namely","neither","never","nevertheless","next",
                                       "nine","ninety","no","nobody","none","nonetheless","noone","nor","not","nothing","now",
                                       "nowhere","of","off","often","on","once","one","one's","only","onto","or","other","others",
                                       "otherwise","our","ours","ourselves","out","over","overall","own","per","perhaps","pm",
                                       "rather","recent","recently","same","seem","seemed","seeming","seems","seven","seventy",
                                       "several","she","she'd","she'll","she's","should","shouldn't","since","six","sixty",
                                       "so","some","somehow","someone","sometime","sometimes","somewhere","still","stop",
                                       "such","taking","ten","than","that","that'll","that's","that've","the","their","them",
                                       "themselves","then","thence","there","thereafter","thereby","there'd","therefore",
                                       "therein","there'll","there're","there's","thereupon","there've","these","they","they'd",
                                       "they'll","they're","they've","thirty","this","those","though","thousand","three","through",
                                       "throughout","thru","thus","to","together","too","toward","towards","trillion","twenty",
                                       "two","under","unless","unlike","unlikely","until","up","upon","us","used","using",
                                       "very","via","was","wasn't","we","we'd","well","we'll","were","we're","weren't","we've",
                                       "what","whatever","what'll","what's","what've","when","whence","whenever","where",
                                       "whereafter","whereas","whereby","wherein","where's","whereupon","wherever","whether",
                                       "which","while","whither","who","who'd","whoever","whole","who'll","whom","whomever",
                                       "who's","whose","why","will","with","within","without","won't","would","wouldn't",
                                       "yes","yet","you","you'd","you'll","your","you're","yours","yourself","you've"};
              int i = 0;
              int j = stoplist.length;
              int mid = 0;
              boolean found = false;
              while (i < j && !found){
                   mid = (i + j)/2;
                   if (str.compareTo(stoplist[mid]) == 0)
                        found = true;
                   else
                        if (str.compareTo(stoplist[mid]) < 0)
                             j = mid;
                        else
                             i = mid + 1;
              return found;
         }

    please show us the full error message.
    it sounds like a classpath problem...

  • NON-SERVLET, NON-EJB DYNAMIC CLASS RELOAD

    hi,
              In weblogic 5.1, is there a way to reload a class from the clientclasses directory without restarting the server? it's just a class in the clientclasses used by the JSPs. a kind of hotdeploy for NON-EJB, NON-SERVLET CLASS. SPECIFIC guidance will be immensely appreciated..
              Thanks in advance
              Vijay
              

    please show us the full error message.
    it sounds like a classpath problem...

  • Retrieve ServletContext from non-servlet class

    A servlet calls a method which is located in another class which is not a servlet. Within this method of the non-servlet class, i need to access the ServletContext of the servlet that has called the method. What i am currently doing is simply passing the ServletContext as a parameter to the method.
    I would like to avoid passing the ServletContext all the time, so i'm wondering if it's possible, from the non-servlet class, to retrieve the ServletContext of the servlet which has called the method of the non-servlet class.

    Thanks J-Fine, that's a smart suggestion. BTW in the meantime i figured out that passing the ServletContext is not that bad idea, after all it reflects the structure of the app. However if i'll change my mind again i'll do like you suggested.

  • Add non-servlet class to Tomcat

    Hi,
    does anyone know, what I have to do, to be able
    to use a simple non-servlet class file in my
    jsp-pages.
    e.g.
    MyClass.class
    In my jsp page:
    <%
    MyClass m = new MyClass( );
    %>
    I was told that I simply have to put it in the
    web-inf/classes directory, but that doesn't seem
    to work ...
    Any help would be appreciated! Thanx. chris

    You need to use the "import" statement or else use the full class name. Also, some servers don't handle the default package well so you may want to try placing the class in a package.
    e.g. if class is mypackage.MyClass, it is placed in web-inf/classes/mypackage/MyClass.class
    In the JSP, code:
    <%@ page import="mypackage.MyClass" %>
    <%
    MyClass m = new MyClass();
    %>or you could use "useBean" to avoid scriptlets.

  • Read web.xml from a non-servlet class

    Hi all, I need to read the web.xml file fron a standard class in a web project.
    I know how to do it from a servlet or a jsp page, but is it possible to do from a non-servlet class?
    Thank you,
    Gabriele

    It's a XML file. So best approach would be to use some Java-XML API to parse the XML file into useable nodes. E.g. JAXP, DOM4J, JXPath, etc.

  • Obtaining Object List programatically

    Hello friends at www.oracle.com,
    I need to know if there's a way for me to obtain a form Object List programatically.
    I already know I can obtain a list of forms' objects by opening it on Forms Builder and opening File menu, and choosing Administration -> Object List Report. However, I would like to know if there's a parameter to be passed to ifbld60.exe that creates such report, or a PL/SQL instruction that could have the same effect.
    Best regards,
    Franklin Gonçalves Jr.

    Anton-
    It's currently a little convoluted, but you can do this:
    Class forClass = YourPersistentClass.class;
    com.solarmetric.kodo.runtime.PersistenceManagerImpl pmi =
    (com.solarmetric.kodo.runtime.PersistenceManagerImpl)pm;
    com.solarmetric.kodo.impl.jdbc.JDBCConfiguration config =
    (com.solarmetric.kodo.impl.jdbc.JDBCConfiguration)pmi.getConfiguration ();
    com.solarmetric.kodo.impl.jdbc.runtime.Connector connector =
    new com.solarmetric.kodo.impl.jdbc.runtime.ConfigurationConnector (config);
    com.solarmetric.kodo.impl.jdbc.SequenceFactory seq =
    config.getSequenceFactory (connector,
    com.solarmetric.kodo.meta.ClassMetaData.getInstance (forClass));
    // get the next value
    long nextValue = seq.getNext (forClass, connector);
    In article <bmegbs$toc$[email protected]>, Anton Kommar wrote:
    Hi,
    Please forgive me for posting again the same question twice (see the Using
    DB sequence question article) but this is critical and urgent for my
    evaluation of the KODO product. Could somebody provide me with the real
    working example of obtaining programatically SequenceFactory for the
    appropriate sequenced fields. I am using the Application identity and have
    sequence fields for every table. The database is Oracle 8. Here are the
    appropriate properties from the kodo properties file:
    com.solarmetric.kodo.impl.jdbc.SequenceFactoryClass=com.solarmetric.kodo.impl.jdbc.schema.ClassSequenceFactory
    # Set the name of the table from which we will be obtaining sequences
    com.solarmetric.kodo.impl.jdbc.SequenceFactoryProperties=TableName=DUAL
    As far as I understand I have to explicitly set the sequence value for my
    Application Identity instances so I need to obtain programatically the
    next sequence value for the PK instances.
    Sorry if I have missed this issue in the documentation but I could not
    find such an example.
    Thanks in advance,
    Anton Kommar--
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • Get real path in non servlet class

    Hi,
    I've created a ServletContextListener class that loads a thread at application startup and kills it and application shutdown.
    The thread periodically monitors a specific file. I need to pass a real file path to the thread, but because the thread class is not a servlet, I cannot use the getServletContext().getRealPath("").
    What are my options?

    The ServletContextListener has access to both the ServletContext as well as the Thread.
    So the solution can be to get the path in the listener and pass it as a parameter to the constructor or a setter method of the thread.

  • Obtaining Object Methods

    Problem:
    I am working with a list of class which are all subclasses of an abstract class.
    I have created an object of each method by the following code:
    Dent Hor = new Horisontal();
    Dent Hin = new Hinged();
    Dent I = new Instant();
    Dent V = new Vertical();
    ClassType ct = new ClassType();
    Object p, q, r;
    p = ct.makeObject("fa.Instant");
    q = ct.makeObject("fa.Horisontal");
    r = ct.makeObject("fa.Hinged");
    I want to handle each DENT as a DENT, yet each DENT object will know what specific class in the hierachy of DENTs it really belongs to.
    Now i when to get the methods in each of the objects.
    Does anyone know how this can be done?
    Thanks

    Here is a bunch of code, origenally based on what you posted above. It only uses Dent and Horizontal for simplicity, it does the printName as you have above, then it calls a bunch of Dent and Horizontal specific methods. I includ my versions of the Dent and Horizontal classes in the same java file, again, just for simplicity...
    package fa;
    public class Test {
         public Object makeObject(String cn) throws ClassNotFoundException,
                                     InstantiationException,
                                     IllegalAccessException
              Object o = Class.forName(cn).newInstance();
              return o;
         public static void main(String[] args)
              Test ct = new Test();
              Dent Hor = new Horizontal();
              Dent r = null;
              try
                   r = (Dent) ct.makeObject("fa.Horizontal");
              } catch (ClassNotFoundException cnfe)
                   cnfe.printStackTrace();
                   System.exit(1);
              } catch (InstantiationException ie)
                   ie.printStackTrace();
                   System.exit(1);
              } catch (IllegalAccessException iae)
                   iae.printStackTrace();
                   System.exit(1);
              ct.printName(r);
              ct.useMethods(r);
         public void printName(Object o)
              Class c = o.getClass();
              String s = c.getName();
              System.out.println(s);
         public void useMethods(Dent r)
              r.dentMethod0();
              r.dentMethod1();
              r.dentMethod2();
              if (r instanceof Horizontal)
                   ((Horizontal)r).horizMethod3();
    abstract class Dent
         void dentMethod0()
              System.out.println("Dent 0");
         void dentMethod1()
              System.out.println("Dent 1");
         abstract void dentMethod2();
    class Horizontal extends Dent
         void dentMethod1()
              System.out.println("---------------");
              super.dentMethod1();
              System.out.println("Horizontal 1");
              System.out.println("---------------");
         void dentMethod2()
              System.out.println("---------------");
              System.out.println("Horizontal 2");
              System.out.println("---------------");
         void horizMethod3()
              System.out.println("---------------");
              System.out.println("Horizontal 3");
              System.out.println("---------------");
    }

  • Accessing ServletContext from non-servlet class

    How i can get information servletcontext from a normal java class?
    I am using Tomcat.
    I have put some Strings in to the servlet context and i want to get this information from a normal java class.
    I think there was a way to do it with getServlet() but this is deprecated.

    One way to do this would be to store the info in some class of your own as a static member(arraylist/hashmap or something) and then retrieve it from your java class.
    May you can populate static field i the init() method of one of your servlet and have that servlet load on tomcat startup.

  • How to obtain object number using cost center??

    hI.
    i need to obtain all the cost elemnts of a particular cost center..
    cost elemnt can b fetched from COSP using OBJNR..
    How do i obtain OBJNR using KOKRS,KOSTL????

    Hi
    From the table
    CSSK
    take the related Cost elements for a cost center.
    Concatenate the cost element with KS and other Orgn unit
    and pass to the Costing tables
    see an entry in those tables you will know what are the fields in OBJNR that are concatenated
    Reward points if useful
    Regards
    Anji

  • Obtaining object reference of a loaded class

    I want to obtain the reference of any class which is allready loaded dynamically.
    I have given a sample code to understand it better...
    I am in a serious need of this solution, Plz. have a look.
    Thankx in advance.
    class FindObjRef
         void find(String obj) throws Exception
              String str1 = new String("Hello!");
              String str2 = new String("World!");
              // Here I want to invoke trim() method (through reflection) on the instance of either str1 or str2 depending what obj parameter contains.
              // I do not want to write a if-else-if statement.
         public static void main(String[] args) throws Exception
              FindObjRef findObj = new FindObjRef();
              findObj.find("str1");
              findObj.find("str2");
    }

    An alternative solution could be a Map, with the variable names as keys and the values as values.

  • Servlet, ejb, wls 510, ClassCastException

    Hello,
              I have an Entity Bean deployed in WLS 5.1.0.
              I wrote a standalone application that obtains the initial context, does a
              lookup, get back
              a home interface, then the business interface (using narrow...), and calls
              business methods...
              Everything works fine...
              BUT....
              The SAME code within a servlet (doGET) does NOT work and throws a
              ClassCastException.
              Is there any issues using EJBs from Servlets?
              Thank you a lot.
              --Thierry
              PS: Here is the code.
              import javax.servlet.http.*;
              import javax.servlet.*;
              import javax.naming.*;
              import javax.ejb.*;
              import javax.rmi.*;
              import org.zol.webstore.ejbs.person.*;
              import java.util.*;
              public final class TestServlet extends HttpServlet {
              * Method init, called when the servlet is initialized
              public void init(ServletConfig sc) throws ServletException {
              System.err.println("@@@@@@@@@@@@ init "+sc);
              * doPost
              * @param req
              * @param res
              protected void doGet(HttpServletRequest req, HttpServletResponse res)
              throws java.io.IOException {
              ServletOutputStream sos = null;
              System.err.println("@@@@@@@@@@@@ doGet ");
              try{
              sos = res.getOutputStream();
              sos.println("<HTML><BODY>");
              sos.println("Test "+new Date()+" <BR>");
              InitialContext initialContext = getInitialContext();
              System.err.println("@@@@@@@@@@@@ Got ic "+initialContext);
              Object pO = initialContext.lookup("person.PersonEntityHome");
              sos.println("<BR>pO: "+pO);
              System.err.println("@@@@@@@@@@@@ Got Object PO ");
              System.err.println("@@@@@@@@@@@@ Checking if we can narrow
              PersonEntityHome");
              Object toNarrow = PortableRemoteObject.narrow(pO,
              PersonEntityHome.class);
              System.err.println("@@@@@@@@@@@@ YES!!!");
              PersonEntityHome pehome = (PersonEntityHome) toNarrow; // FAILS
              sos.println("<BR>pehome: "+pehome);
              System.err.println("@@@@@@@@@@@@ Got PE HOME ");
              sos.println("</BODY></HTML>");
              } catch (Exception eee) {
              sos.println(eee.getMessage());
              eee.printStackTrace();
              public InitialContext getInitialContext() {
              InitialContext ic = null;
              try {
              Hashtable h = new Hashtable();
              h.put(Context.INITIAL_CONTEXT_FACTORY,
              "weblogic.jndi.WLInitialContextFactory");
              h.put(Context.PROVIDER_URL, "t3://localhost:7001");
              ic = new InitialContext(h);
              } catch (Exception e) {
              e.printStackTrace();
              return ic;
              

    Doesn't that mean that you can't hot deploy the EJB now?
              -rrc
              Thierry Janaudy wrote:
              > Put the classes in the WEBLOGICCLASSPATH...
              > And now it does work....
              >
              > Thank you Thierry,
              >
              > Your Welcome.
              >
              > Thierry
              >
              > Thierry Janaudy <[email protected]> wrote in message
              > news:[email protected]...
              > > Hello,
              > >
              > > I have an Entity Bean deployed in WLS 5.1.0.
              > > I wrote a standalone application that obtains the initial context, does a
              > > lookup, get back
              > > a home interface, then the business interface (using narrow...), and calls
              > > business methods...
              > > Everything works fine...
              > >
              > > BUT....
              > >
              > > The SAME code within a servlet (doGET) does NOT work and throws a
              > > ClassCastException.
              > > Is there any issues using EJBs from Servlets?
              > >
              > > Thank you a lot.
              > > --Thierry
              > >
              > > PS: Here is the code.
              > > --------------------------------------------------------------------------
              > --
              > > ----------------
              > >
              > > import javax.servlet.http.*;
              > > import javax.servlet.*;
              > > import javax.naming.*;
              > > import javax.ejb.*;
              > > import javax.rmi.*;
              > > import org.zol.webstore.ejbs.person.*;
              > > import java.util.*;
              > >
              > > public final class TestServlet extends HttpServlet {
              > >
              > > /**
              > > * Method init, called when the servlet is initialized
              > > */
              > > public void init(ServletConfig sc) throws ServletException {
              > > System.err.println("@@@@@@@@@@@@ init "+sc);
              > > }
              > >
              > > /**
              > > * doPost
              > > * @param req
              > > * @param res
              > > */
              > > protected void doGet(HttpServletRequest req, HttpServletResponse res)
              > > throws java.io.IOException {
              > > ServletOutputStream sos = null;
              > >
              > > System.err.println("@@@@@@@@@@@@ doGet ");
              > >
              > > try{
              > > sos = res.getOutputStream();
              > >
              > > sos.println("<HTML><BODY>");
              > > sos.println("Test "+new Date()+" <BR>");
              > >
              > > InitialContext initialContext = getInitialContext();
              > >
              > > System.err.println("@@@@@@@@@@@@ Got ic "+initialContext);
              > >
              > > Object pO = initialContext.lookup("person.PersonEntityHome");
              > > sos.println("<BR>pO: "+pO);
              > >
              > > System.err.println("@@@@@@@@@@@@ Got Object PO ");
              > >
              > > System.err.println("@@@@@@@@@@@@ Checking if we can narrow
              > > PersonEntityHome");
              > > Object toNarrow = PortableRemoteObject.narrow(pO,
              > > PersonEntityHome.class);
              > >
              > > System.err.println("@@@@@@@@@@@@ YES!!!");
              > >
              > > PersonEntityHome pehome = (PersonEntityHome) toNarrow; // FAILS
              > >
              > > sos.println("<BR>pehome: "+pehome);
              > >
              > > System.err.println("@@@@@@@@@@@@ Got PE HOME ");
              > >
              > > sos.println("</BODY></HTML>");
              > > } catch (Exception eee) {
              > > sos.println(eee.getMessage());
              > > eee.printStackTrace();
              > > }
              > > }
              > >
              > >
              > > public InitialContext getInitialContext() {
              > > InitialContext ic = null;
              > >
              > > try {
              > > Hashtable h = new Hashtable();
              > > h.put(Context.INITIAL_CONTEXT_FACTORY,
              > > "weblogic.jndi.WLInitialContextFactory");
              > > h.put(Context.PROVIDER_URL, "t3://localhost:7001");
              > > ic = new InitialContext(h);
              > > } catch (Exception e) {
              > > e.printStackTrace();
              > > }
              > >
              > > return ic;
              > > }
              > > }
              > >
              > >
              Russell Castagnaro
              Chief Mentor
              SyncTank Solutions
              http://www.synctank.com
              Earth is the cradle of mankind; one does not remain in the cradle forever
              -Tsiolkovsky
              

  • Servlet configuration in Weblogic 5.1.. web.xml vs weblogic.properties..

    Can someone please tell me how the <servlet> entry differs from
              weblogic.httpd.register.snoop=examples.servlets.SnoopServlet
              in weblogic properties?
              Do these perform identical functions?
              

    Yes this is the source of my confusiong. It seems to be that WL can be told
              about servlets
              two ways. Firstly through the web.xml file and also via weblogic.properties.
              I don't understand
              why the second one exists.
              "Cameron Purdy" <[email protected]> wrote in message
              news:[email protected]...
              > I only work with WAR files, so I cannot speak to non-WARd servlets with
              any
              > confidence. I know that WL could use web.xml for non-WARd servlets in
              order
              > to obtain the other information associated with the servlet:
              >
              > <!ELEMENT servlet (icon?, servlet-name, display-name?, description?,
              > (servlet-class|jsp-file), init-param*, load-on-startup?,
              > security-role-ref*)>
              >
              > --
              >
              > Cameron Purdy
              > http://www.tangosol.com
              >
              >
              > "Robert Nicholson" <[email protected]> wrote in message
              > news:[email protected]...
              > > If what you say is true then why is there the need to also tell WL about
              > the
              > > servlets themselves?
              > >
              > > Presumably this is for when the servlets exist outside of a WAR then?
              > >
              > > "Cameron Purdy" <[email protected]> wrote in message
              > > news:[email protected]...
              > > > The weblogic.properties tells WL to load a WAR or specific servlet.
              The
              > > > <servlet> entry (I assume you refer to
              > > > http://java.sun.com/j2ee/dtds/web-app_2_2.dtd) defines the presence of
              a
              > > > servlet within a WAR (a deployment unit):
              > > >
              > > > >
              > > > The servlet element contains the declarative data of a
              > > > servlet. If a jsp-file is specified and the load-on-startup element is
              > > > present, then the JSP should be precompiled and loaded.
              > > > [end-quote]
              > > >
              > > > In the case of a WAR deployment, you have to tell WL that the WAR
              > exists,
              > > > then it will look in the WAR and figure out what servlets are there
              from
              > > the
              > > > <servlet> tags in your web.xml. You set up a WAR in the
              > > weblogic.properties
              > > > as such:
              > > >
              > > > weblogic.httpd.webApp.<http-path>=<os-path>
              > > >
              > > > For example:
              > > > weblogic.httpd.webApp.website=c:/weblogic/website.war
              > > >
              > > > --
              > > >
              > > > Cameron Purdy
              > > > http://www.tangosol.com
              > > >
              > > >
              > > > "Robert Nicholson" <[email protected]> wrote in message
              > > > news:[email protected]...
              > > > > Can someone please tell me how the <servlet> entry differs from
              > > > >
              > > > > weblogic.httpd.register.snoop=examples.servlets.SnoopServlet
              > > > >
              > > > > in weblogic properties?
              > > > >
              > > > > Do these perform identical functions?
              > > > >
              > > > >
              > > >
              > > >
              > >
              > >
              >
              >
              

Maybe you are looking for