Javabean destroy

I'm using a Java Bean in my application. An HTML page invokes a bean's method that opens a database connection, saving it into the same bean. I would like to know how to do to close the connection when I close the application and I delete the bean.
Thanks in advance.
Daniele.

I answered a similar question a while ago. See this thread:
http://forum.java.sun.com/thread.jsp?forum=39&thread=174092

Similar Messages

  • Destroy in JavaBean with application scope?

    Hi,
    I am using a java bean in my jsp application with scope "application". I know that this java bean will be terminated only when the server stops or shuts down (Apache Tomcat 5.5).
    I need to cleanup something manually when the server shuts down. Can anyone tell me what method will be called, or that I can override, to clean up?
    I tried finalize and valueUnbound (implements HttpSessionBindingListener) with no luck... I just can't find a equivalent to destroy in Servlets (I can't use servlets, must use javabeans+jsp)...
    Any sugestion?
    thanks in advance for your time

    There is an indirect way if you know servlets. The "application" implicit object that you use in your JSP is the javax.servlet.ServletContext object. Instead of declaring your bean using the jsp:useBean tag, directly put your objects into the ServletContext using ServletContext.putAttribute() method. Objects put in the ServletCOntext are available to all pages in the application. Just use the ServletContext.getAttribute() method to retrieve this bean in any other page.
    To "kill the bean", just reset the value of this object to null by calling putAttribute(null).

  • Unable to get my javabean working

    I am running iWS6 with Java2 1.4 on Win NT4sp6. I have problem getting my javabeans to work. There is no problems when i try to run jsp or web-apps. Here is the error message I see:
    [10/Apr/2002:10:47:25] info ( 271): Suspend Httpd Service
    [10/Apr/2002:10:47:26] info ( 271): vs(https-sgp-web.sci.sing.seagate.com)Closing the web applications
    [10/Apr/2002:10:47:26] info ( 271): vs(https-sgp-web.sci.sing.seagate.com)destroyed 0 servlets in web application /servlet
    [10/Apr/2002:10:47:27] info ( 249): successful server startup
    [10/Apr/2002:10:47:27] info ( 249): iPlanet-WebServer-Enterprise/6.0SP1 B08/20/2001 01:49
    [10/Apr/2002:10:47:28] info ( 249): Installing a new configuration
    [10/Apr/2002:10:47:28] info ( 249): [LS ls1] http://sgp-web.sci.sing.seagate.com, port 80 ready to accept requests
    [10/Apr/2002:10:47:28] info ( 249): A new configuration was successfully installed
    [10/Apr/2002:10:47:29] info ( 249): Loading IWSSessionManager by default.
    [10/Apr/2002:10:47:29] info ( 249): IWSSessionManager: Maximum number of sessions is 1000
    [10/Apr/2002:10:47:29] info ( 249): Adding web application (/servlet) at (D:/SP_Seagate/webapps)
    [10/Apr/2002:10:47:29] info ( 249): Loading IWSSessionManager by default.
    [10/Apr/2002:10:47:29] info ( 249): IWSSessionManager: Maximum number of sessions is 1000
    [10/Apr/2002:10:47:29] info ( 249): Successfully initialized web application environment (web-apps.xml) for virtual server (https-sgp-web.sci.sing.seagate.com)
    [10/Apr/2002:10:47:42] info ( 249): Internal Info: loading servlet /departments/eis/SetName.jsp
    [10/Apr/2002:10:47:44] info ( 249): JSP: JSP1x compiler threw exception
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    D:\iPlanet\Servers\https-sgp-web.sci.sing.seagate.com\config\..\ClassCache\_jsps\_departments\_eis\_SetName_jsp.java:60: Class jsps.departments._eis.Contact not found.
    Contact contactbean = null;
    ^
    D:\iPlanet\Servers\https-sgp-web.sci.sing.seagate.com\config\..\ClassCache\_jsps\_departments\_eis\_SetName_jsp.java:63: Class jsps.departments._eis.Contact not found.
    contactbean= (Contact)
    ^
    D:\iPlanet\Servers\https-sgp-web.sci.sing.seagate.com\config\..\ClassCache\_jsps\_departments\_eis\_SetName_jsp.java:68: Class jsps.departments._eis.Contact not found.
    contactbean = (Contact) Beans.instantiate(this.getClass().getClassLoader(), "Contact");
    ^
    3 errors, 1 warning
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:284)
         at com.iplanet.server.http.servlet.NSServletEntity.load(NSServletEntity.java:252)
         at com.iplanet.server.http.servlet.NSServletEntity.update(NSServletEntity.java:173)
         at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:410)
    [10/Apr/2002:10:47:44] warning ( 249): Internal error: Failed to get GenericServlet. (uri=/departments/eis/SetName.jsp,SCRIPT_NAME=/departments/eis/SetName.jsp)
    Another question is do i have to implement the bean as a web app?
    thanks
    mh

    It may be an import problem.
    in the jsp you need both
    <%@ page import="Contact" %>
    and
    <jsp:useBean id="contactbean" scope="session" class="Contact"

  • Problem to connect to mysql from servlet using a javabean

    Hi,
    I'm new here and beginner on java to.
    I have problem to connect to MySql database, by a connection javabean.
    It's the following: a HTML page calls a servlet and this servlet imports the package connection javabean.
    It has no problem when I establish the connection inside the servlet, with all its methods (public and private). But i want to separate the code connection from servlet.
    Detail: there is no problem, using the javabean to connect to MS Access database.
    I put "mysql-connector-java-3.1.12-bin.jar" file inside WEB-INF/lib application and common/lib directories.
    I set the classpath:
    SET CLASSPATH=%CATALINA_HOME%\COMMON\LIB\mysql-connector-java-3.1.12-bin.jar;%CLASSPATH%
    I think that the servlet cannot create an instance of javabean, because passed by catch exception of the servlet init method.
    But I don't know why.
    Please Why?
    Below there are the fragment of errors, servlet code e javabean code.
    Thank you.
    Zovao.
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.lang.NullPointerException
    at CadServletFileBeanConexArq.doPost(CadServletFileBeanConexArq.java:47)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
    Note: The line 47 is calling insertIntoDB javabean method.
    ========///////////////===============
    // Here is the servlet CadServletFileBeanConexArq.java
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.sql.*;
    import conJdbc.*;
    public class CadServletFileBeanConexArq extends HttpServlet {
    public ConexPed connect = null;
    private String driver = "com.mysql.jdbc.Driver";
    private String URL = "jdbc:mysql://localhost:3306/cadastro";
    public void init( ServletConfig config )
    throws ServletException
    super.init( config );
    try
    connect = new ConexPed(driver, URL, "monty", "some_pass");
    catch ( Exception e )
    e.printStackTrace();
    connect = null;
    public void doPost( HttpServletRequest req,
    HttpServletResponse res )
    throws ServletException
    boolean success = true;
    String email, nome, sobrenome, produto, valor;
    email = req.getParameter( "Email" );
    nome = req.getParameter( "Nome" );
    sobrenome = req.getParameter( "Sobrenome" );
    produto = req.getParameter( "Produto" );
    valor = req.getParameter( "Valor" );
    res.setContentType( "text/html" );
    if ( email.length() > 0 && nome.length() > 0 && sobrenome.length() > 0 && valor.length() > 0 )
    /* inserting data */
    success = connect.insertIntoDB(
    "'" + email + "','" + nome + "','" + sobrenome + "','" + produto + "'", Double.parseDouble(valor) );
    //closing connection
    public void destroy()
    connect.fecharConexao();
    =============///////////////============
    Here is the JavaBean.
    package conJdbc;
    import java.sql.*;
    public class ConexPed
    public Connection connection;
    public Statement statement;
    public ConexPed (String driver, String urlServidor, String user, String password)
    try
    Class.forName(driver);
    connection = DriverManager.getConnection(urlServidor,user,password);
    catch (ClassNotFoundException ex)
    System.out.println("N�o foi poss�vel encontrar a classe do Driver: " + driver);
    catch (SQLException ex)
    System.out.println("N�o foi poss�vel conectar ao servidor");
    try
    statement = connection.createStatement();
    catch (SQLException ex)
    System.out.println("N�o foi poss�vel criar a statement");
    *Inserting data to database
    public synchronized boolean insertIntoDB( String stringtoinsert, double valor)
    try
    statement.executeUpdate( "INSERT INTO pedido values (" + stringtoinsert + " , " + valor + ");" );
    catch ( Exception e ) {
    System.err.println(
    "ERROR: Problemas ao adicionar nova entrada" );
    e.printStackTrace();
    return false;
    return true;
    * Close statement.
    public void fecharStatement()
    try
    statement.close();
    catch (SQLException ex)
    ex.printStackTrace();
    * close database
    public void fecharConexao()
    try
    connection.close();
    catch (SQLException ex)
    ex.printStackTrace();
    }

    Hi,
    I'm new here and beginner on java to.
    I have problem to connect to MySql database, by a connection javabean.
    It's the following: a HTML page calls a servlet and this servlet imports the package connection javabean.
    It has no problem when I establish the connection inside the servlet, with all its methods (public and private). But i want to separate the code connection from servlet.
    Detail: there is no problem, using the javabean to connect to MS Access database.
    I put "mysql-connector-java-3.1.12-bin.jar" file inside WEB-INF/lib application and common/lib directories.
    I set the classpath:
    SET CLASSPATH=%CATALINA_HOME%\COMMON\LIB\mysql-connector-java-3.1.12-bin.jar;%CLASSPATH%
    I think that the servlet cannot create an instance of javabean, because passed by catch exception of the servlet init method.
    But I don't know why.
    Please Why?
    Below there are the fragment of errors, servlet code e javabean code.
    Thank you.
    Zovao.
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.lang.NullPointerException
    at CadServletFileBeanConexArq.doPost(CadServletFileBeanConexArq.java:47)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
    Note: The line 47 is calling insertIntoDB javabean method.
    ========///////////////===============
    // Here is the servlet CadServletFileBeanConexArq.java
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.sql.*;
    import conJdbc.*;
    public class CadServletFileBeanConexArq extends HttpServlet {
    public ConexPed connect = null;
    private String driver = "com.mysql.jdbc.Driver";
    private String URL = "jdbc:mysql://localhost:3306/cadastro";
    public void init( ServletConfig config )
    throws ServletException
    super.init( config );
    try
    connect = new ConexPed(driver, URL, "monty", "some_pass");
    catch ( Exception e )
    e.printStackTrace();
    connect = null;
    public void doPost( HttpServletRequest req,
    HttpServletResponse res )
    throws ServletException
    boolean success = true;
    String email, nome, sobrenome, produto, valor;
    email = req.getParameter( "Email" );
    nome = req.getParameter( "Nome" );
    sobrenome = req.getParameter( "Sobrenome" );
    produto = req.getParameter( "Produto" );
    valor = req.getParameter( "Valor" );
    res.setContentType( "text/html" );
    if ( email.length() > 0 && nome.length() > 0 && sobrenome.length() > 0 && valor.length() > 0 )
    /* inserting data */
    success = connect.insertIntoDB(
    "'" + email + "','" + nome + "','" + sobrenome + "','" + produto + "'", Double.parseDouble(valor) );
    //closing connection
    public void destroy()
    connect.fecharConexao();
    =============///////////////============
    Here is the JavaBean.
    package conJdbc;
    import java.sql.*;
    public class ConexPed
    public Connection connection;
    public Statement statement;
    public ConexPed (String driver, String urlServidor, String user, String password)
    try
    Class.forName(driver);
    connection = DriverManager.getConnection(urlServidor,user,password);
    catch (ClassNotFoundException ex)
    System.out.println("N�o foi poss�vel encontrar a classe do Driver: " + driver);
    catch (SQLException ex)
    System.out.println("N�o foi poss�vel conectar ao servidor");
    try
    statement = connection.createStatement();
    catch (SQLException ex)
    System.out.println("N�o foi poss�vel criar a statement");
    *Inserting data to database
    public synchronized boolean insertIntoDB( String stringtoinsert, double valor)
    try
    statement.executeUpdate( "INSERT INTO pedido values (" + stringtoinsert + " , " + valor + ");" );
    catch ( Exception e ) {
    System.err.println(
    "ERROR: Problemas ao adicionar nova entrada" );
    e.printStackTrace();
    return false;
    return true;
    * Close statement.
    public void fecharStatement()
    try
    statement.close();
    catch (SQLException ex)
    ex.printStackTrace();
    * close database
    public void fecharConexao()
    try
    connection.close();
    catch (SQLException ex)
    ex.printStackTrace();
    }

  • Urgent!!!!a question about javabean....

    hello all:
    I set a javabean named mybean in request scope,and set it as valueRef of a form.
    first : form is show data from mybean .
    then : when user edit the form and submit to post,the edit data in form will update to javabean ,but can't not find javabean because the bean has been destroyed by system when show date from mybean in the end of first step.
    how to solve this trouble... please...

    That's because you've put the bean in the request scope : request object dies when servlet or JSP sends info back to the browser and closes the stream (ie : when page is shown in client browser).
    An easy solution is to put the bean in session scope.

  • Databases and JavaBeans

    I have a servlet which connects and queries an MS Access database. I want to be able to do this in a JavaBean if its possible? I want to be able to use this in a JSP can anyone help me with this?
    Here is my servlet:
    package database;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    import ap.servlets.*;
    * @author szyszlo
    * @version
    public class albumquery extends HttpServlet {
    Connection dbCon;
    /** Initializes the servlet.
    public void init() throws ServletException {
    try{
    String dbURI = null;
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    dbCon = DriverManager.getConnection("jdbc:odbc:odbc_exmp2");
    catch (ClassNotFoundException e){
    System.out.println("Database driver could not be found");
    System.out.println(e.toString());
    throw new UnavailableException (this, "Database driver class not found");
    catch (SQLException e){
    System.out.println("Error connecting to database");
    System.out.println(e.toString());
    throw new UnavailableException(this, "Can't connect to the database");
    } // End of the method init() ....
    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException{
    ResultSet rs;
    Statement stmt;
    StringBuffer qry = new StringBuffer(1024);
    int numCriteria = 0;
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    String album = req.getParameter("ddlbalbum");
    String _track = req.getParameter("txt_track");
    String _writer = req.getParameter("ddlb_writer");
    qry.append("SELECT * FROM Albums WHERE");
    if(_album.length() > 0){
    qry.append(" album LIKE '%");
    qry.append(_album);
    qry.append("%' AND");
    numCriteria++;
    if(_track.length() > 0){
    qry.append(" track LIKE '%");
    qry.append(_track);
    qry.append("%' AND");
    numCriteria++;
    if(_writer.length() > 0){
    qry.append(" writer LIKE '%");
    qry.append(_writer);
    qry.append("%' AND");
    numCriteria++;
    if(numCriteria > 0){
    qry.delete(qry.length() - 3, qry.length());
    else{
    qry.delete(qry.length() - 5, qry.length());
    try{
    stmt = dbCon.createStatement();
    rs = stmt.executeQuery(qry.toString());
    catch (SQLException e){
    res.sendError(res.SC_ACCEPTED, "The request has been accepted, but it failed to complete due to a problem querying the database");
    return;
    html h = new html("Search Results");
    h.add(html.HEADING, "KISS Albums", true);
    h.add(html.LINE, " ", false);
    String labels[] = {"Album","Track","Song Writer"};
    if(!h.addTable(labels, rs)){
    res.sendError(res.SC_ACCEPTED, "The request has been accepted, but it failed to complete due to a problem accessing the data");
    return;
    out.println(h.getPage());
    out.close();
    } // End of the method doGet ....
    public void destroy(){
    try{
    dbCon.close();
    catch(Exception e){
    System.out.println("Database close failed");
    System.out.println(e.toString());
    } // End of method destroy ....
    } // End of servlet ....
    Thanks

    simple :
    1. out the init part into the consructor of the bean u
    want to make .
    2. the remaining part will go to a instance mathod sae
    doworkForMe.
    3. in the jsp page create an instance as
    <jsp:useBean id="myb" scope="session" class="myBean"
    />
    4. call the method by passing the request object to
    it.
    I know this maybe a simple thing to do but could you give me an example of how to do this?
    Thanks

  • Submit URL to Servlet from javaBean

    I am trying to make a call to servlet through URL in my javabean and its not working out. calculateFedexRates class is working fine. If I call the same servlet from oracle PL/sQL package using util_http packge, it works just fine. But here in java bean I get error as follows:
    I just dont know what is wrong am I doing? Please help.
    Thanks.
    here is my java bean.
    ---------------------public class submiturltoservlet {
    public static void main(String[] args) {
                                    try {
                                    String data = URLEncoder.encode("ds", "UTF-8") + "=" + URLEncoder.encode("0", "UTF-8");
                                            data += "&" + URLEncoder.encode("weight", "UTF-8") + "=" + URLEncoder.encode("10.03", "UTF-8");
                                    data += "&" + URLEncoder.encode("fromState", "UTF-8") + "=" + URLEncoder.encode("IL", "UTF-8");
                                    data += "&" + URLEncoder.encode("fromZip", "UTF-8") + "=" + URLEncoder.encode("60133", "UTF-8");
                                    data += "&" + URLEncoder.encode("toState", "UTF-8") + "=" + URLEncoder.encode("IL", "UTF-8");
                                    data += "&" + URLEncoder.encode("toZip", "UTF-8") + "=" + URLEncoder.encode("60601", "UTF-8");
                                    data += "&" + URLEncoder.encode("shipDate", "UTF-8") + "=" + URLEncoder.encode("2009-02-05", "UTF-8");
                                    URL url = new URL("myurl/fedex/getFedexRates?weight=10.03&fromState=IL&fromZip=60133&toState=IL&toZip=60601&shipDate=2009-02-05");
                                    URLConnection conn = url.openConnection();
                                    conn.setDoOutput(true);
                                    ((HttpURLConnection)conn).setRequestMethod("GET");
                                    conn.setUseCaches(false);
                                    OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
                                    wr.write(data);
                                    wr.flush();
                                   BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                                   String line;
                                   while ((line = rd.readLine()) != null) {
                                        System.out.println("Response: " + line);
                                   wr.close();
                                   rd.close();
                                } catch (Exception e) {
                                    System.out.println("print out a stack trace and exit");
                                            e.printStackTrace();
            } // end of main
    }               // End of class
    here is my servlet.
    public class getFedexRates extends HttpServlet {
        public void init() {
        public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
           String weight = request.getParameter("weight");
               String fromState= request.getParameter("fromState");
               String fromZip= request.getParameter("fromZip");
               String toState= request.getParameter("toState");
               String toZip= request.getParameter("toZip");
               String shipDate= request.getParameter("shipDate");
               calculateFedexRates calculatefedrate = new calculateFedexRates();
            response.setContentType("text/plain");
            PrintWriter out = response.getWriter();
            out.println(calculatefedrate.calculate(weight,fromState,fromZip,toState,toZip, shipDate));
            out.close();
            out.flush();
            public void destroy() {
    Error I get :
    java.io.IOException: Server returned HTTP response code: 405 for URL: http://myurl/fedex/getFedexRates?weight=10.03&fromState=IL&fromZip=60133&toState=IL&toZip=60601&shipDate=2009-02-05
            at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:800)
            at submiturltoservlet.main(submiturltoservlet.java:34)

    HTTP status code 405 means "method not allowed". So the other side doesn't support GET or POST request.
    I am not sure what the request method is after all. The setDoOutput(true) triggers POST, but you're forcing it to GET afterwards. Why this? It look like that you rather want a GET, so leave the setDoOutput(true) away and that other line too. If it still returns a 405, then you should probably be using POST rather than GET. In this case use setDoOutput(true) and write the query string to the body of the request rather than in URL.

  • ITunes 6.0.3 destroyed my music files (mp3 and m4a).

    iTunes 6.0.1 has destroyed a significant amount of my 35,000 song library. Not just the library, but the SONG FILES. Take a look:
    http://riggswerks.com/itunes/diy_gaps.gif
    This is an mp3 file that has been opened in Peak. See all those gaps? They were added by iTunes.
    What happens is when a song that has been damaged like this goes to play, iTunes will only play it till its first gap (in the case of the screenshot song, about 2 seconds). Once it hits the gap, it moves on to the next song in the playlist. For some reason, iTunes is adding the gaps and duplicating small portions of the song in between the gaps, cutting off several seconds of the song ending, etc. So, it wouldn't be as simple as cutting out the gaps in a sound editing program, because song data has been added as well. The files are useless. I tried to upload one, but my ftp client wouldn't allow a file that severely damaged to be moved.
    Two questions:
    a) Is iTunes 6.0.1 safe to use? I'm scared to death that it will end up trashing more of my music, so I reverted to version 5, and locked my dedicated 250GB music hard drive. Anyone out there that can help explain what's going on would be tremendously helpful.
    and
    b) It seems that once there is a screwed up song in the iTunes library, it forces any overwritten file for the bad songs to adopt the gaps and characteristics of the previous version. For example, I reburned a couple of these bad songs from the original CD and selected for iTunes to replace the songs as they burned (after unlocking the hard drive)- when I went to play it, the new song- ripped straight from CD minutes before- had the same gapping problems. How can I reimport my good versions of these files if iTunes adopts the gaps and errors? I'm stuck.
    For further reference (others have had similar/same issues):
    http://discussions.apple.com/message.jspa?messageID=1308126#1308126
    http://discussions.apple.com/message.jspa?messageID=1308121#1308121
    http://discussions.apple.com/message.jspa?messageID=1308060#1308060
    http://discussions.apple.com/message.jspa?messageID=1307909#1307909
    For those who may know how to help- here's my set up:
    PowerMac G5 Quad running 10.4.3
    iTunes 6.0.1 (reverted back to iTunes 5 now)
    TIA. core4

    hiya!
    hmmm. okay, here's a user tip on moving your music files to a different drive. can you spot anything you might have missed on the first attempt?
    MacMuse: Move iTunes music/Library to new drive
    love, b

  • What is the diffrence between a javabean and  EJB

    hi!
    what is the diffrence between a javabean and entreprise jvaabeans! i mean which are the uitilization featires of eaxh one !

    i am seeking for a solution for my problem , in fact i ma trying to implement and develop an application with java that allows a certain range of IP adresses to be connected to a database server in order to extract the suitable data from the server .
    let me explain mor ethe suitation , in fact what i am loking for is to use javabeans to grant my application much more consistence and pertinence : si i am asking if it could be possible to use javabeans in my case especially if i am not trying to developp a web application but a cleint /server one allowing some services.
    The application is in fact dealing with a stock exchange market and what i am trying to do is to grant particilar registrated customers to have the informations that they need ( portofolio, currency's status, market indicators, .) also drawing some charts decribing rates, variations, and others specefic financial caracterestics .So , if we consider that this application is not a web application ( no HTTP request and no servers like apache or others ) how it is possible to use javabeans and not EJB to build the application? i mean what could be suitable and preferable to rely on and dvelop to ensure a good java application !!
    if you need more details to help you find the answer for me don't hesitate to answer me back !!
    Someone here gave me that answer
    use RMI to code the services and (Updateable) Value Objects to pass the information between tiers.
    RMI is an all-java distributed component framework (ie. EJB, CORBA, DCE/RPC, DCOM, etc.), that is very suitable for developing non-containerized multi-tier applications. Refer to the RMI trail in the Java Tutorial as a starting point for coding RMI solutions (http://java.sun.com/docs/books/tutorial/index.html). Under this scenario you would code the database access service as an RMI service (server-side). Client/server communication should be facilitated through the use of JavaBeans/classes that wrap the information being passed (customer information, portfolio details, market information, etc.) - these are refered to as 'Updateable Value Objects' (a design pattern). Graphing and charting would be handled in your client from the information received from the (RMI) server. GUI JavaBeans can be used to provide this functionality as well as other client-side services. There are numerous "shrink-wrapped" components for GUIs available on the market just peruse any Java magazine to find them.
    but how comes? how can i do it !! and where can i find more information please about 'Updateable Value Object "
    thanks

  • Servlet agent for 3 days without destroy()

    hello,
    i've wrote a java program, that calculates every hour a key and write the key it into a file. now i want to change the program into a servlet.
    my problem:
    i want to start the servlet like this:
    www.myurl.com/servlet/myservlet?start=true
    then i want to leave my website and the servlet should begin to calculate every hour (if i'm on the wesite or not).
    it should be possible to break the servlet with
    www.myurl.com/servlet/myservlet?start=false
    i don't really know, but i think, that the servlet will be destroy if i leave my website and will not calculate and write in my file anymore.
    is there a possibility to do that (perhaps overwriting destroy())???
    the key calculation in my java program is in an extra thread.
    hope somone can help me,
    thanks,

    you don't need to start or stopp the servlet. Servlets are started automaticaly upon the first request for that servlet. Or, if you like, you can define a servlet to startup automaticaly when the serlvet runners starts.
    Like this, you just have to handle your "main proccess". I would implement a thread in the servlet init() and do all the processessing in there. With the commands like ?stop or ?start you can simply start or stop the thread.

  • Classloader difference in init() and destroy()?

    I was getting a ClassNotFoundException (see below) inside a log4j call from my servlet destroy() method. To test, I attempted the same log4j call from my servlet init() method and it works just fine. In fact, in this test, since the class is already loaded at init time it finds it successfully at destroy time (ie. the log4j call is successful). But, if I take the call out of init and the class in not loaded anywhere prior to destroy(), it fails with the ClassNotFoundException in destroy(). Anybody have any insight on this one? Thanks.
              The exception stack dump:
              java.lang.NoClassDefFoundError: org/apache/log4j/spi/ThrowableInformation
                   at org.apache.log4j.spi.LoggingEvent.<init>(LoggingEvent.java:145)
                   at org.apache.log4j.Category.forcedLog(Category.java:372)
                   at org.apache.log4j.Category.info(Category.java:691)
              I'm using log4j version 1.2.7.
              I'm importing org.apache.log4j.Logger;
              I instantiate in my class: private Logger theLog = Logger.getLogger(this.getClass());
              I'm calling: theLog.info(String s, Throwable e);

    Where do you have the log4j.jar? It sounds like the ClassFinder for that jar has already been closed (as part of the undeployment) by the time your destroy is called.
              -- Rob
              WLS Blog http://dev2dev.bea.com/blog/rwoollen/

  • Select-options are not destroyed while calling view of used component popup

    Hi Friends ,
    I'm facing a unique problem. I'm calling a view of a component within another component. the view that I'm calling has some select-options. When I close the popup window ( using close 'X' of popup ) and then try to reopen the popup system give me a dump. I debugged and found that select-options are not destroyed by system and once it tries to create the select-options again it dumps because they are already there.  
    This is the source code extract of that dump for your reference .
    1 method if_wd_select_options~add_selection_field.
    2
    3   data:
    4     lr_table_descr       type ref to cl_abap_tabledescr,
    5     lr_struct_descr      type ref to cl_abap_structdescr,
    6     lr_value_field_descr type ref to cl_abap_elemdescr,
    7     added_field          like line of mt_added_fields,
    8     dfies                type dfies,
    9     description          type string,
    10     complex_restrictions type if_wd_select_options=>t_complex_restrictions.
    11
    12   field-symbols:
    13     <it_result> type index table.
    14
    15 * check of someone wants to add a field that already exists
    16   read table mt_fields
    17        with key m_id = i_id
    18        transporting no fields.
    19   if sy-subrc = 0.
    20 *   might be deleted - recreating a field with different setting is of course allowed
    21     read table mt_all_removed_fields
    22          with key table_line = i_id
    23          transporting no fields.
    24     if sy-subrc <> 0.
    >>>       message x000(00).
    26     endif.
    27
    28 *   remove the existing field in order to avoid duplicates
    29     delete table mt_fields with table key m_id = i_id.
    30   endif.
    I've already tried using REMOVE_ALL_SEL_SCREEN_ITEMS( ) method of interface IF_WD_SELECT_OPTIONS before creating new elements ( select-options ). If any one can help me in this It would really help and I'll appreciate it.
    Thanks in advance,
    Laeeq

    I've sloved the problem

  • Locked out of my ipad plese help dont want to loose any files on it (he can destroy a anvil with a 16oz.hammer

    Someone please help the kid locked me outa my new ipad and says cant remember the numbers i cant lose any files nd no longer have computer that set it up help me (did i mention he can destroy a anvil with a 16oz.hammer)

    Use a friend's computer.
    iOS: Device disabled after entering wrong passcode
    http://support.apple.com/kb/ht1212
    How can I unlock my iPad if I forgot the passcode?
    http://tinyurl.com/7ndy8tb
    How to Reset a Forgotten Password for an iOS Device
    http://www.wikihow.com/Reset-a-Forgotten-Password-for-an-iOS-Device
    Using iPhone/iPad Recovery Mode
    http://ipod.about.com/od/iphonetroubleshooting/a/Iphone-Recovery-Mode.htm
    Saw this solution on another post about an iPad in a school enviroment. Might work on your iPad so you won't lose everything.
    ~~~~~~~~~~~~~
    ‘iPad is disabled’ fix without resetting using iTunes
    Today I met my match with an iPad that had a passcode entered too many times, resulting in it displaying the message ‘iPad is disabled – Connect to iTunes’. This was a student iPad and since they use Notability for most of their work there was a chance that her files were not all backed up to the cloud. I really wanted to just re-activate the iPad instead of totally resetting it back to our default image.
    I reached out to my PLN on Twitter and had some help from a few people through retweets and a couple of clarification tweets. I love that so many are willing to help out so quickly. Through this I also learned that I look like Lt. Riker from Star Trek (thanks @FillineMachine).
    Through some trial and error (and a little sheer luck), I was able to reactivate the iPad without loosing any data. Note, this will only work on the computer it last synced with. Here’s how:
    1. Configurator is useless in reactivating a locked iPad. You will only be able to completely reformat the iPad using Configurator. If that’s ok with you, go for it – otherwise don’t waste your time trying to figure it out.
    2. Open iTunes with the iPad disconnected.
    3. Connect the iPad to the computer and wait for it to show up in the devices section in iTunes.
    4. Click on the iPad name when it appears and you will be given the option to restore a backup or setup as a new iPad (since it is locked).
    5. Click ‘Setup as new iPad’ and then click restore.
    6. The iPad will start backing up before it does the full restore and sync. CANCEL THE BACKUP IMMEDIATELY. You do this by clicking the small x in the status window in iTunes.
    7. When the backup cancels, it immediately starts syncing – cancel this as well using the same small x in the iTunes status window.
    8. The first stage in the restore process unlocks the iPad, you are basically just cancelling out the restore process as soon as it reactivates the iPad.
    If done correctly, you will experience no data loss and the result will be a reactivated iPad. I have now tried this with about 5 iPads that were locked identically by students and each time it worked like a charm.
    ~~~~~~~~~~~~~
    Try it and good luck. You have nothing more to lose if it doesn't work for you.
     Cheers, Tom

  • Cannot a get JSP page instance from a page being destroyed

    We have a J2EE app, using Struts + Tiles (build 1.1-b3), running on Win2KPro, Ora9ias v9.0.3. The application is roles-based, and different users see different versions of the same page based on their role authorizations. Occasionally, when multiple users in different roles are requesting the same page, the app returns the following exception:
    OracleJSP:
    JSP Error:
    Request URI:/fast/WEB-INF/jsp/tiles/layouts/baseLayout.jsp
    Exception:
    javax.servlet.ServletException: Cannot a get JSP page instance from a page being destroyed
         at oracle.jsp.runtimev2.JspPageInstFacade.getInstance(JspPageInstFacade.java:147)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:303)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
         at com.gal.fast.portal.web.SessionInitializedFilter.doFilter(SessionInitializedFilter.java:105)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:556)
         at com.evermind.server.http.ServletRequestDispatcher.include(ServletRequestDispatcher.java:119)
         at org.apache.struts.tiles.TilesUtilStrutsModulesImpl.doInclude(TilesUtilStrutsModulesImpl.java:124)
         at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:161)
         at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:703)
         at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:818)
         at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:467)
         at web2d_inf._jsp._tiles._layouts._baseLayout._jspService(_baseLayout.java:445)
         [SRC:/WEB-INF/jsp/tiles/layouts/baseLayout.jsp:149]
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
         at com.gal.fast.portal.web.SessionInitializedFilter.doFilter(SessionInitializedFilter.java:105)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:556)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:209)
         at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1033)
         at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:269)
         at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:249)
         at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:303)
         at org.apache.struts.action.RequestProcessor.processActionForward(RequestProcessor.java:401)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:505)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at com.gal.fast.portal.web.FastActionServlet.service(FastActionServlet.java:110)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
         at com.gal.fast.portal.web.SessionInitializedFilter.doFilter(SessionInitializedFilter.java:105)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:556)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:148)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:72)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:536)
    All the code in the two custom classes above ( com.gal.fast.portal.web.SessionInitializedFilter and com.gal.fast.portal.web.FastActionServlet ) has been commented out to the point that they are NOOP stubs.
    We only see this with multiple near-simultaneous requests for the same page with differet roles. It smells like a threading issue to me, but I'm no expert (hence this post). Any thoughts?
    --matt

    We have a J2EE app, using Struts + Tiles (build 1.1-b3), running on Win2KPro, Ora9ias v9.0.3. The application is roles-based, and different users see different versions of the same page based on their role authorizations. Occasionally, when multiple users in different roles are requesting the same page, the app returns the following exception:
    OracleJSP:
    JSP Error:
    Request URI:/fast/WEB-INF/jsp/tiles/layouts/baseLayout.jsp
    Exception:
    javax.servlet.ServletException: Cannot a get JSP page instance from a page being destroyed
         at oracle.jsp.runtimev2.JspPageInstFacade.getInstance(JspPageInstFacade.java:147)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:303)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
         at com.gal.fast.portal.web.SessionInitializedFilter.doFilter(SessionInitializedFilter.java:105)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:556)
         at com.evermind.server.http.ServletRequestDispatcher.include(ServletRequestDispatcher.java:119)
         at org.apache.struts.tiles.TilesUtilStrutsModulesImpl.doInclude(TilesUtilStrutsModulesImpl.java:124)
         at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:161)
         at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:703)
         at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:818)
         at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:467)
         at web2d_inf._jsp._tiles._layouts._baseLayout._jspService(_baseLayout.java:445)
         [SRC:/WEB-INF/jsp/tiles/layouts/baseLayout.jsp:149]
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
         at com.gal.fast.portal.web.SessionInitializedFilter.doFilter(SessionInitializedFilter.java:105)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:556)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:209)
         at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1033)
         at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:269)
         at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:249)
         at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:303)
         at org.apache.struts.action.RequestProcessor.processActionForward(RequestProcessor.java:401)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:505)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at com.gal.fast.portal.web.FastActionServlet.service(FastActionServlet.java:110)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
         at com.gal.fast.portal.web.SessionInitializedFilter.doFilter(SessionInitializedFilter.java:105)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:556)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:148)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:72)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:536)
    All the code in the two custom classes above ( com.gal.fast.portal.web.SessionInitializedFilter and com.gal.fast.portal.web.FastActionServlet ) has been commented out to the point that they are NOOP stubs.
    We only see this with multiple near-simultaneous requests for the same page with differet roles. It smells like a threading issue to me, but I'm no expert (hence this post). Any thoughts?
    --matt

  • Problem retrieving javabean instance from request in JSP

    I am using WSAD and I created a javabean called confirmBean in default package which contains two private properties fname, lname and public setters and getters
    In a servlet I placed values in the bean, then placed the bean in a request and then forwarded to confirm.jsp
    confirmBean cb = new confirmBean();
    cb.setFname("testing");
    req.setAttribute("mybean", cb);     
    req.getRequestDispatcher("/confirm.jsp").forward(req,res);
    Here is my JSP, I used java syntax for retrieving javabean:
    <HTML>
    <HEAD>
    <TITLE>confirm.jsp</TITLE>
    </HEAD>
    <%@ page
    language="java"
    contentType="text/html; charset=ISO-8859-1"%>
    <%@ page import="confirmBean"%>
    <BODY>
    <% confirmBean myBean = (confirmBean)request.getAttribute("MYBEAN"); %>
    <%= myBean.getFname() %>
    </BODY>
    </HTML>
    and here is the error i am getting when executing:
    Error 500: Unable to compile class for JSP c:\testWorkspace\.metadata\.plugins\com.ibm.etools.server.core\tmp0\cache\localhost\server1\Test\TestWeb.war\_confirm.java:3: '.' expected import confirmBean; ^ An error occurred at line: 11 in the jsp file: /confirm.jsp Generated servlet error: c:\testWorkspace\.metadata\.plugins\com.ibm.etools.server.core\tmp0\cache\localhost\server1\Test\TestWeb.war\_confirm.java:78: cannot resolve symbol symbol : class confirmBean location: class org.apache.jsp._confirm confirmBean myBean = (confirmBean)request.getAttribute("MYBEAN"); ^ An error occurred at line: 11 in the jsp file: /confirm.jsp Generated servlet error: c:\testWorkspace\.metadata\.plugins\com.ibm.etools.server.core\tmp0\cache\localhost\server1\Test\TestWeb.war\_confirm.java:78: cannot resolve symbol symbol : class confirmBean location: class org.apache.jsp._confirm confirmBean myBean = (confirmBean)request.getAttribute("MYBEAN"); ^ 3 errors
    Please help!!!!

    1 - Put your bean in a proper package. As of Java1.4 classes in the default package are not visible :
    http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=c85f07c1ce8f344d787b7a5146d68:WuuT?bug_id=43615752 - As a matter of style, class names should always start with a capital letter. ie ConfirmBean
    3 - Rather than declaring the bean, and retrieving it, from the request manually, have a useBean tag:
    <jsp:useBean id="MYBEAN" class="com.mypackage.ConfirmBean" scope="request"/>
    of course the id has to be the same as the attribute in scope.
    Hope this helps,
    evnafets

Maybe you are looking for

  • Creating an Azure VM from an existing snapshot, does not automalically create a certificate for remoting

    Hi, As the title says, I have problems with an Azure VM created from an image I captured of an Azure VM. For easier deployment of my server I created one, running everything on localhost, such that I could take an image of it and re-deploy this image

  • All about Process codes

    Hi all, Iam doing IDOC( Stock Transfer)--XIFile Scenario. Q) For this Do we really need to mention the Process code at We20 --in Outbound Parameters side???? Regards Suman

  • Safari Is Constantly Crashing (2)...

    Safari cannot stay operating for more than a minute. I had to install Firefox to post this. The report is: Process: Safari [278] Path: /Applications/Safari.app/Contents/MacOS/Safari Identifier: com.apple.Safari Version: 3.2.1 (5525.27.1) Build Info:

  • When opening a link in mail the following message appears

    The message : canot find entrypoint ?DIIBlocklist_Initialize@@YAXXZ in DLL file. Can you help me Thanks Ron

  • IOS 8 won't install on my 4S

    I have tried twice to install iOS 8 on my iPhone 4S. The installation goes all the way, the phone restarts and iOS 7.1.2 is still there. I go on software update and iOS 8 is available so I download it again completes install and it is not there! 7.1.