Object living with servlet/jsp container

How do I make an Object live until the servlet container lives? I mean I want an Object to be instantiated once in the lifetime of the webserver session and its has to be singleton and should live alive until the webserver dies? How can I make this possible? I should be able to keep that object alive even if any no references are made to the object. Moreover I should be able to access that object from any java class on that webserver?

You can't do this in memory. The easiest thing to do would be to read/write the persistant data you need from disk.
Anything your JSP or servlet creates in memory will be cleared when it is done serving the request.

Similar Messages

  • Object living along with servlet/jsp container

    How do I make an Object live until the servlet container lives? I mean I want an Object to be instantiated once in the lifetime of the webserver session and its has to be singleton and should live alive until the webserver dies? How can I make this possible? I should be able to keep that object alive even if any no references are made to the object. Moreover I should be able to access that object from any java class on that webserver?

    if mean u want to keep the object live for
    one user session
    use session.setAttribute("name",object)
    and if mean for the time btw start up and shutdown of the
    server use application scope
    alternatively
    use session scope in bean or application scope as needed
    like
    <jsp:useBean id="db_in" scope="session" class="com.ww.ert.Bean_IN" />
    or
    <jsp:useBean id="db_in" scope="application" class="com.ww.ert.DatabaseBean_IN" />
    Regards
    manu

  • The ELResolvers for JSF were not registered with the JSP container

    I'm trying to configure mojarra on tomcat6 (because I want to use Elastic Beanstalk). tomcat complains:
    Feb 8, 2011 10:24:17 AM com.sun.faces.lifecycle.ELResolverInitPhaseListener populateFacesELResolverForJsp
    INFO: JSF1027: [null] The ELResolvers for JSF were not registered with the JSP container.
    I have tried all sorts of combinations of replacing EL2.2 libs in tomcat/lib, putting the libs in WEB-INF/lib, and the context param:
    <context-param>
    <param-name>com.sun.faces.expressionFactory</param-name>
    <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
    </context-param>
    JSF pages seem to work but I'd rather have a clean startup. Please assist. Thx in advance.

    Thx for replying.
    I have jstl-1.2.jar:
         <dependency>
                   <groupId>javax.servlet</groupId>
                   <artifactId>jstl</artifactId>
                   <version>1.2</version>
    <scope>provided</scope>
              </dependency>
    Which version numbers are you referring to in *.xml? The following?
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">
    <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">

  • Tomcat servlet/JSP container default files on 10gAS(10.1.2.0.2)

    Hi Friends,
    I am using Oracle Application Server 10g (10.1.2.0.2) on windows
    I have the Vulnerability: Apache Tomcat servlet/JSP container default files.
    and the fix is Review the files and delete those that are not needed.
    i would like to know the location of the files to review and delete.Please suggest?
    Regards,
    DB

    Apache/Tomcat is not related to OAS, where did you get this info? OAS is based in a Orion Web Server and Apache HTTP Server, not Tomcat.
    For this kind of problems there are the CPU you may want to check in Metalink for them.
    Can you clarify also what default files?
    Greetings.

  • Java Webconsole ELResolvers for JSR not registered with the JSP container

    Trying to rebuild a LDAP server running Directory Server 6.1. Just installed Solaris 10 u9 on a SunFire V240. Loaded most recent recommended patch set dated 2011.02.02. Proceeded to load Directory Server V6.0 from native packages using JAVA ES Installer. After Directory Server installation and initialization the Java Webconsole is running but brings up a blank page login page. Note: Did not test the Webconsole prior to Directory Server installation. The errors in the /var/log/webconsole/console/console_debug_log file state:
    Feb 8, 2011 10:32:32 AM com.sun.faces.lifecycle.ELResolverInitPhaseListener populateFacesELResolverForJsp
    INFO: JSF1027: [console] The ELResolvers for JSF were not registered with the JSP container.
    Feb 8, 2011 10:32:34 AM com.sun.faces.lifecycle.Phase doPhase
    SEVERE: JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /jsp/login/BeginLogin.jsp) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@13c3b45]
    The JAVA version is: 1.6.0_22
    The cacao version is 2.2.4.1
    Kernel Patch is Generic_144488-06
    Anyone have an idea what is causing this problem for the JAVA webconsole and how to fix it?

    hi,
    it is tomcat-6.0.20, JSF-RI 2.0.2 (Mojarra)
    a whole bunch of libs and jquery4jsf (though really buggy in this manner, because all components could you rewrite for JSF2-components, etc.)
    Unfortunately it is somehow a config error, because i haven't got it earlier, since i changed PhaseListener and Authentification with JAAS (sample from Ed Burns:
    http://weblogs.java.net/blog/2006/03/07/repost-using-jaas-jsf, but with JDBC-based authentification)
    cheers,
    Istvan

  • IPlanet as a servlet/jsp container

    is it possible to use IPlanet server as a servlet/jsp Container.if it is then tell the guidelines

    Yeah, and Apache is a more configurable/robust HTTP server. Tomcat has only a basic HTTP server built-in.
    It is also a dessert topping.

  • Help with Servlet - JSP Newbie

    I'm trying to teach myself jsp. I've created a couple of classes to do my data I/O. I have a form to collect user data and the page the form posts to should write the data to a text file. When I run the form and form handler the data is presented back to the user and everything looks fine... no errors or anything. However, the text file I'm trying to create/append does not get modified. Any suggestions would be greatly appreciated as I can't move on with what I want to do until I figure this out.
    Thanks,
    Steven Lee / EMC
    [email protected]
    I'm running Apache 2.0.52/Tomcat 5.5 on Win 2000. Here's my directory structure:
    C:\Apache\Tomcat 5.5.\webapps\ROOT
    /ROOT
    index.jsp
    OptIn.jsp
    show_email_entry
    /admin
    /WEB-INF -->web.xml
    /classes
    /business -->User.class
    /data -->UserIO.class
    /lib
    ***UserIO.class:***
    package data;
    import java.io.*;
    import business.User;
    public class UserIO{
    public synchronized static void addRecord(User user, String filename)
              throws IOException{
                   PrintWriter out = new PrintWriter(
                        new FileWriter(filename, true));
                   out.println(user.getEmailAddress() + "|"
                        + user.getFirstName() + "|"
                        + user.getLastName() );
                   out.close();
    ***User.class***
    package business;
    public class User {
         private String firstName;
         private String lastName;
         private String emailAddress;
         public User() {}
         public User(String first, String last, String email) {
         firstName = first;
         lastName = last;
         emailAddress = email;
         public void setFirstName(String f) {
              firstName = f;
         public String getFirstName() { return firstName; }
         public void setLirstName(String l) {
              lastName = l;
         public String getLastName() { return lastName; }
         public void setEmailAddress(String e) {
              emailAddress = e;
         public String getEmailAddress() { return emailAddress; }
    ***OptIn.jsp***
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    <body>
    <p>Join E- Mail List</p>
    <form action="show_email_entry.jsp" method="get" name="FRMjoinList" id="FRMjoinList">
    <input name="txFN" type="text" id="txFN">
    first name
    <br>
    <input name="txLN" type="text" id="txLN">
    last name <br>
    <input name="txEMAIL" type="text" id="txEMAIL">
    e-mail <br>
    <input type="submit" name="Submit" value="Submit">
    </form>
    <p> </p>
    </body>
    </html>
    ***show_email_entry.jsp***
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    <body>
    <%@ page import="business.*, data.*, java.util.Date" %>
    <%
         String firstName = request.getParameter("txFN");
         String lastName = request.getParameter("txLN");
         String emailAddress = request.getParameter("txEMAIL");
         User user = new User(firstName, lastName, emailAddress);
         UserIO.addRecord(user, "UserEmail.txt");
    %>
    <p>Today's Date is <%=new Date() %></p>
    <H2>Thanks for joining our list</H2>
    <p>Here's your information:</p>
    <table width="300" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="92">First Name </td>
    <td width="208"><%=user.getFirstName() %></td>
    </tr>
    <tr>
    <td>Last Name </td>
    <td><%=user.getLastName() %></td>
    </tr>
    <tr>
    <td>E-Mail</td>
    <td><%=user.getEmailAddress() %></td>
    </tr>
    </table>
    <p>Click here to enter another address.</p>
    <form name="form1" method="post" action="optIn.jsp">
    <input type="submit" value="Return">
    </form>
    <p> </p>
    </body>
    </html>

    I just realized that the file is given as just a filename. No path.
    Are you SURE the file isn't being created, just somewhere you don't expect?
    Try putting a full path in there instead of just a filename.

  • Help me with mail sending with servlets/jsp

    : doe any one have a clue as to how to send a mail via jsp/servlets.

    An obvious solution is to use JavaMail. It is part of j2EE.

  • How is object handled with servlets?

    Hi!
    This is probably a very basic question, but I need to know. Does a servlet treat objects differently from any other Java class?
    Consider you have the following class:
    public class ClassC {
         private String strName = "John";
         public String getName() {
              return strName;
         public void setName(String name) {
              strName = name;
    }Then we use a servlet to create a object of class ClassC:
         public void doGet(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException, IOException {
              String strFirstName= "Steve";
              ClassC c = new ClassC();
              c.setName("Lance");
              strFirstName = c.getName();
              response.setContentType("text/html");
              PrintWriter out = response.getWriter();
              out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
              out.println("<HTML>");
              out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
              out.println("  <BODY>");
              out.println("strFirstName = " + strFirstName);
              out.println("  </BODY>");
              out.println("</HTML>");
              out.flush();
              out.close();
         } My question is what �out.println("strFirstName = " + strFirstName);� will print in a server on the webb?
    Suppose you have a produced a ResultSet and you put that as a private variable in a class as in ClassC above. Suppose I use the same technique as in the doGet-method, and have methods that extract data from the ResultSet. Will each use user of the servlet get unique information or will every user get the same information?
    I think (and hope) that each user will get unique information. Is this correct?
    Regards
    Jonas

    As written... the object Class is local to to the doGet method. This means that each run of the doGet method gets its own instance of the object, and each user will get their own data.
    If strFirstName or c was declared as a class member, then all users would get the same data (potentially):
    //bad servlet:
      String strFirstName = "Steve";
      ClassC c;
      public void doGet(...) ... {
        c = new ClassC();
      }

  • How To Use A .dll Object in Java Servlet/JSP

    I need the Solution, Is there any API's Available to do so.
    Ofcourse The .dll is a Microsoft Visual Basic Product.

    You need to use JNI to wrap C/C++ function provided by the .dll library. and then call it from JNI implementation class.
    [email protected]
    http://www.sinotar.com/

  • Best IDE for developing Applets,Servlets,JSP

    Hi,
    I'm looking for a little bit of advise. I have been developing prototypes using Apache Tomcat. Now I need to go into a full development phase, and I need an IDE to help speedup my work, especially when it comes to debugging applets and servlets. So the following are my questions:
    1. What is the best IDE to use in conjunction with Apache Tomcat? Does JBuilder, for example, fit this bill?
    2. Outside of Apache, I believe there is for example IBM's Websphere, which includes an IDE and a Servlet/JSP container. Which is the best of these packages?
    Thank you for your help.
    Miguel

    Check out NetBeans 3.5 at www.netbeans.org

  • Javascript not working when JSP container changed. Why?

    I'm migrating from Resin (if you happen to know what it is) to Tomcat.
    My web app runs fine on Tomcat, without any change in the code. What surprises me is that, javascript, which works perfectly fine while the webapp runs on Resin, seems to have problems when the webapps runs on Tomcat.
    This does not seem to make sense to me: javascript is executed on the client (browser) and should have nothing to do with the JSP container.
    Can someone tell me why, and how to fix this? Thanks!

    see if your browser supports something like a javascript console or debugger.
    e.g.:
    - MS InternetExplorer shows a warning icon in the left bottom corner if there is a javascript error. doubleclicking on it shows the error type and the location (url, line, char) where the error occured.
    - Mozilla supports a javascript console which shows up javascript errors or warnings.
    have a look at what the browser says on your errors.
    if your javascripts are hardcoded it HAS TO BE a browser (misinterpretation) or javascript error. serverside has definitively nothing to do with javascript...
    greetz,
    Thof

  • How to find the servlet, jsp version available for SunOne 7 webserver

    hi ,
    I am looking for a command that can say the version of servlet, JSP container in Sun One7 webserver.
    as in weblogic we can do by command
    java weblogic.version -verbose
    is similar type of command is available for SunOne 7 web server

    Hi,
    Ask BASIS person to check the JMS driver which is installed on XI through visual admin.
    Thnx
    Chirag

  • Ejb + servlet + jsp

    Hallo everybody,
    i try to develop an application with servlet jsp and ejbs but i don't have enough information about this thema.
    for example i want to make a simple login szenario :
    user type the name and passwd and the system contact with the db and show a wellcome page if the login is succesfull and an error page if the login is unsuccessfull.
    which component does was??
    the first page can be a html form and post the name and passwd to a servlet.
    in this case servlet can make a connection with the DB and can forward the user to next page or error page. BUT where should i use EJB? can i realize the db connection with ejb ? if yes how can interact the servlet with the ejb and how can i store the information (for example address of user) which i have taken from the DB?
    thanks a lot

    Thanks for the antwort
    this means that the servlet connected to DB and execute the sql to authenticate user??
    and the second part is my bigger problem :)
    what does it mean "it will pass the control
    to the enterprise java bean which will be housing the business logic for your application."
    what does a java bean really do? how can i find information about them?
    and is ther an example in which i can see how servlets, jsps and beans interact??
    thanks

  • Want to run servlets, jsp and ejb

    Hi there, I have just installed Oracle9iAS on my PC and want to check how to use OAS with servlets, JSPs and ejbs, so can any one tell me where can I find some worked examples and step by step deployment process, any help would be appreciated, regards, Shabbier

    If you have installed Oracle9iAS, you should be able to get to the welcome page at
    http://<machine_name>:7778/
    You can see J2EE demos off that page.
    Also, you can find info about oracle9iAS and documentation
    at http://otn.oracle.com/products/ias/content.html
    OC4J info can be found at
    http://otn.oracle.com/tech/java/oc4j
    -Prasad

Maybe you are looking for