How to catch exception in JSP????

how to catch exception in JSP?
I use JDeveloper 3.1
I use connection with database .
When I insert record in database
when have duplicate of primary key
how to catch this exception and
back to previous page?
I trying with folowing:
<jsp:useBean id="RowEditor" class="oracle.jbo.html.databeans.EditCurrentRecord" scope="request">
<% try {
RowEditor.setUseJS(true);
RowEditor.initialize(pageContext, "package2_Package2Module.Drzavi1View");
RowEditor.setSubmitText("Save");
RowEditor.setTargetUrl("Drzavi1View_SubmitInsertForm.jsp");
RowEditor.createNewRow();
RowEditor.setReleaseApplicationResources(true);
RowEditor.render();
catch(Exception e) {
%>
<script>
alert("primary key duplication");
history.back();
</script>
<% } %>
but i't not working
please help me

i catch exceptions as you do, i don't have any problem...
are you throwing the exception from your bean?
actually i don't catch an Exception, but an SQLException...
but it works... here is my code...
     try
myclass.addElement(); // this is an insert into Oracle
catch( DataBaseFailException e ) /// an exception that i throws inside after i receive an SQLException
          session.setAttribute("gMessage","e.getMessage()); // error code

Similar Messages

  • How to run exception using JSP?

    How to run exception using JSP?

    Why would you need the <%%> between the if else blocks? Even if you attempt to write some data within the blocks in java, you will still get an error. For example, this is illegal:
    if(done)
        System.out.println(true);
    System.out.println("Hello World");
    else
        System.out.println(false);
    }The compiler is expecting the 'else' to be directly after the body of the if. If it encounters anything else, it will complain. So you cannot do this in jsp either, regardless if it's a different technology, it's the same compiler.

  • How to catch exception when have max connection pool

    hi,
    i have define in oracle user that i could have max 10 sessions at the same time.
    I have jdbc datasource & connection pool defined at glassfish server(JSF application).
    now, if in application is too many queries to the database then i have error: nullpointer exception - becouse when i try to do:
    con = Database.createConnection(); - it generates nullpointer exception becouse there isn't free connection pool
    i try to catch exception like this:
    public List getrep_dws_wnioski_wstrzymane_graph() {     int i = 0;     try {     con = Database.createConnection();     ps =    (Statement) con.createStatement();     rs = ps.executeQuery("select data, klasa, ile_dni_wstrzymana, ile_wnioskow from stg1230.dwsww_wstrzymane_dws8 order by data, klasa, ile_dni_wstrzymana, ile_wnioskow");     while(rs.next()){       rep_dws_wnioski_wstrzymane_graph.add(i,new get_rep_dws_wnioski_wstrzymane_graph(rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4)));       i++;     }     } catch (NamingException e) {         e.printStackTrace();     } catch (SQLException e) {         e.printStackTrace();     } catch (NullPointerException e) {         e.printStackTrace();         throw new NoConnectionException();  // catch null 1     } finally {     try {         con.close();     } catch (SQLException e) {         e.printStackTrace();     } catch (NullPointerException e) {         e.printStackTrace();         throw new NoConnectionException();  // catch null 2     }     } return rep_dws_wnioski_wstrzymane_graph; }
    but at line:
    con.close();
    i have nullpointerexception
    and
    at line
    throw new NoConnectionException(); // catch null 2
    i have: caused by exception.NoConnectionException
    what's wrong with my exception class? how to resolve it?
    public class NoConnectionException extends RuntimeException{     public NoConnectionException(String msg, Throwable cause){       super(msg, cause);     }     public NoConnectionException(){       super();     } }
    at web.xml i have defined:
    <error-page>         <exception-type>exception.NoConnectionException</exception-type>         <location>/NoConnectionExceptionPage.jsp</location>     </error-page>

    thanks,
    i did it and i have error:
    java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: ORA-02391: exceeded simultaneous SESSIONS_PER_USER limit
    at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:115)
    at logic.Database.createConnection(Database.java:37): conn = ds.getConnection();
    public class Database {
         public static Connection createConnection() throws NamingException,
                    SQLException {
                Connection conn = null;
                try{
                    Context ctx = new InitialContext();
              if (ctx == null) {
                   throw new NamingException("No initial context");
              DataSource ds = (DataSource) ctx.lookup("jdbc/OracleReports");
              if (ds == null) {
                   throw new NamingException("No data source");
              conn = ds.getConnection();  // here's exception when max connections to database
              if (conn == null) {
                   throw new SQLException("No database connection");
                } catch (NamingException e) {
                    e.printStackTrace();
                    throw new NoConnectionException(); 
             } catch (SQLException e) {
                 e.printStackTrace();
                    throw new NoConnectionException(); 
                catch (NullPointerException e) {
                 e.printStackTrace();
                    throw new NoConnectionException();  // obsluga bledy na wypadek jesli braknie wolnych polaczen do bazy
            return conn;
    }and at my ealier code i have error:
    at logic.GetDataOracle.getrep_dws_wnioski_wstrzymane_graph(GetDataOracle.java:192)
    at line: con = Database.createConnection();
    in code:
    public List getrep_dws_wnioski_wstrzymane_graph() {
        int i = 0;
        try {
        con = Database.createConnection();
        ps =    (Statement) con.createStatement();
        rs = ps.executeQuery("select data, klasa, ile_dni_wstrzymana, ile_wnioskow from stg1230.dwsww_wstrzymane_dws8 order by data, klasa, ile_dni_wstrzymana, ile_wnioskow");
        while(rs.next()){
          rep_dws_wnioski_wstrzymane_graph.add(i,new get_rep_dws_wnioski_wstrzymane_graph(rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4)));
          i++;
        } catch (NamingException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (NullPointerException e) {
            e.printStackTrace();
            throw new NoConnectionException();
        } finally {
        try {
            if(con != null)
            con.close();
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (NullPointerException e) {
            e.printStackTrace();
            throw new NoConnectionException(); 
    return rep_dws_wnioski_wstrzymane_graph;
    }so what's wrong?
    i have limit max sessions 10 at oracle so i set at my connection pool 5 connections as max. But when i get max 5 sesssins and try to execute next query then i can't catch exception..

  • Can not catch exception in jsp?

    It sames that it is not a must to catch exception potentially throwed.The following snippet can work well.But if in a standard java file ,we should catch the naming exception.How to explain this phenomena?
    <%! int a=8;%>
              <%
              System.out.println("begin jsp");
              Hashtable h=new Hashtable();
              h.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
              h.put(Context.PROVIDER_URL,"jnp://127.0.0.1:1099");
              InitialContext ic=new InitialContext(h);
              CalcHome ch=(CalcHome) ic.lookup(CalcHome.JNDI_NAME);
              System.out.println("begin create cal");
              Calc c=ch.create();
              a=c.calcBonus(2,2);
              System.out.println(a);
              %>
              <%=a%>

    But don't forget to have isErrorPage="true" or it will ignore the try/catch, at least with my server (IPlanet).
    I have actually found it much nicer to have a full error page with JSP. All my JSP pages have errorPage set to an error.jsp and isErrorPage set to false.
    This means no try/catch blocks anywhere muddying up code. Just the error page has all the catches. I like it.

  • How to catch exception into a String variable ?

    I have a code
    catch(Exception e)
                e.printStackTrace();
                logger.error("\n Exception in method Process"+e.getMessage());
            }when i open log i find
    Exception in method Process null.
    But i get a long error message in the server console !! I think thats coming from e.printStackTrace().
    can i get the error message from e.printStackTrace() into a String variable ?
    I want the first line of that big stacktrace in a String variable.
    How ?

    A trick is to issue e.printStackTrace() against a memory-based output object.
    void      printStackTrace(PrintStream s)
             // Prints this throwable and its backtrace to the specified print stream.
    void      printStackTrace(PrintWriter s)
    //          Prints this throwable and its backtrace to the specified print writer.Edited by: BIJ001 on Oct 5, 2007 8:54 AM

  • How to catch exception of JMS when call onMessage()?

    I write a consumer client implement onMessage(),
    in my main() method ...
    try {
    _adapter = new Adapter(checkConsumer,env);
    _adapter.setSelector("client = 'Receive1'");
    _adapter.start();
    System.out.println("Hello...");
    } catch(Exception e) {
    _adapter = null;
    System.out.println("Unable to start adapter: " + e.getMessage());
    _adapter.start() will call onMessage() my onMessage like this
    public void onMessage(Adapter adpt, Message message) {
    try {
    if(message instanceof TextMessage) {
    // Write the text out as read String text = ((TextMessage)message).getText();
    // Do CHECK Process adpt.demoOut("Receive CHECK Text is :" + text);
    //System.out.println("class name is " + consumerName);
    } else {
    // This is just a message (no particular type) } } catch (Exception e) {
    try {
    adpt.warn("Error outputing data: " + message.getJMSMessageID());
    } catch(Exception ignore) {
    } adpt.warn("\tError: " + e.getMessage());
    // Do some exception process }
    If the JMS Server shutdown, how can I catch the exception?

    You might want to try with exception listener that JMS specification provides.

  • How to catch exception throw bc4j

    Dear Forum
    I am user of JDeveloper Swing application.
    while exception throw from bc4j some particular
    type error such as (oracle.jbo.DMLException) JBO-26041
    message display.
    i want to catch error no 26041 inorder to display own
    messageBox.
    There is two methods
    1-:
    i used messageBundle class i overite message string but unable to change dialogBox,i want to use own dialog.
    2-:
    And i fund ,DML exception message return from JUErrorHandlerDlg class.So using this subclass how
    to catch and throw own message.
    Plase send me some code to write sub class of JUErrorHandlerDlg.

    You want this method System to throw an exception if the String[] is empty?
    public void system( ObjectOutputStream output, String cmd []  ) {
       if (cmd.length == 0)
          throw new IllegalArgumentException("Hey! This is an empty array!");
    //...rest of your method
    }You can choose for yourself which exception type is most appropriate. You can in theory always use the base Exception but is not very specific nor recommended. In this case, I think an existing unchecked exception such as IllegalArgumentException would be the most appropriate.

  • How to catch exception thrown from a function module?

    Hi all,
             When we are calling a function module from JSPDynpage setting some import parameters, If in some case an exception is thrown in the function module.  How can we catch the same exception in the JSPDynpage program?
    Thanks & Regards,
    Ravi

    Hi Ravi
                                    Try this
                                                try
                    Object retMsgs = output.get(bapiretrunmsgobject);
                      if(result != null )
    IrecordSet rmsg = (IrecordSet) result
                   catch(Exception ex)
                        printException(ex, "Error getting function result");
    Lemme know for any further questions.
    Regards
    Praveen

  • How to catch ClassCastException from JSP page?

    I get a ClassCastException within my JSP page and I know where my bug is. However, this classcastexception message is displayed in the browser and I want to catch this exception to also log it into my log file. But I can't find the place where to catch it: in my servlet's doPost() method I can't catch it - i tried it by enclosing the method body with try/catch but it isn't catched. I wonder if I can catch it at all or if this error is handled internally in the servlet engine?

    It should only be displayed in the browser if you're not catching the exception in the jsp itself. If the exception is happening in the jsp, then there's no point in trying to catch it in the servlet.
    What happens if you put a try-catch just around the actual code in the jsp? You could put it around the entire jsp, but that's not necessary.
    One problem I've encountered in catching exceptions is if there are escape sequences within the try block, for example:
    try{
       //java code
    %>
       <!--html -->
    <%
    //java
    catch (Exception e)I'm not sure if that works or not, but to be safe, make sure you're not escaping from jsp within the try block.

  • Help Me, How to catch exception thrown from ejbStore

    Hi,
    I am working on application running on Iplanet Application Server 4.0. Problem is the application exception thrown from the ejbStore don't reach the calling servlet, calling servlet receive TransactionRollback exception which is system exception. But there is no sign of my application exception thrown from ejbStore. Can anybody tell me how I can get my ApplicationException thrown from ejbStore in my calling servlet.
    I am calling entity beans set method in servlet and in entity bean ejbStore method I am throwing Application exception.
    in entity bean
    public void ejbStore() throws MyException
    if(true) throw new MyException();
    in servlet
    try {
    MyEntityHome home = .......
    MyEntityRemote remote = home.findBy.....
    remote.setMyValue(MyValue value); //Transaction required Container managed
    }catch(MyException e) {
    e.printStackTrace(); // Not cahcing My Exception
    }catch(Exception e) {
    e.printStackTrace(); //catching TransactionRolledBackException
    Thanks
    Shakti

    Hi Ravi
                                    Try this
                                                try
                    Object retMsgs = output.get(bapiretrunmsgobject);
                      if(result != null )
    IrecordSet rmsg = (IrecordSet) result
                   catch(Exception ex)
                        printException(ex, "Error getting function result");
    Lemme know for any further questions.
    Regards
    Praveen

  • How to catch exception while validating the username and password in hbm

    Hi,
    I do want to set the username and password dynamically in hibernate.cfg.xml
    Here below is my configuration file.
    {code<hibernate-configuration> 
    <session-factory> 
           <property name="hibernate.bytecode.use_reflection_optimizer">false</property> 
           <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property> 
           <property name="hibernate.connection.pool_size">10</property> 
           <property name="show_sql">true</property> 
           <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property> 
           <property name="hibernate.hbm2ddl.auto">update</property> 
           <property name="current_session_context_class">thread</property> 
           <property name="show_sql">true</property> 
         </session-factory> 
    </hibernate-configuration>{code}
    Also im getting that session factory object like the below code.
    public class Sessions {        private static SessionFactory sessionFactory;      private static Configuration configuration = new Configuration();        static {          try {              String userName = GuigenserviceImpl.userName;              String password = GuigenserviceImpl.password;              String hostName = GuigenserviceImpl.hostName;              String portNo = GuigenserviceImpl.portNo;              String sId = GuigenserviceImpl.sId;                  configuration                      .setProperty("hibernate.connection.username", userName);              configuration                      .setProperty("hibernate.connection.password", password);              configuration.setProperty("hibernate.connection.url",                      "jdbc:oracle:thin:@" + hostName + ":" + portNo + ":" + sId);                try {              configuration.configure("/hibernate.cfg.xml");              sessionFactory = configuration.buildSessionFactory();              GuigenserviceImpl.strAccpted = "true";              }              catch (Exception e) {                    e.printStackTrace();                  GuigenserviceImpl.strAccpted = "false";              }            }          catch (HibernateException hibernateException) {              GuigenserviceImpl.strAccpted = "false";              hibernateException.printStackTrace();          }          catch (Throwable ex) {                GuigenserviceImpl.strAccpted = "false";              ex.printStackTrace();              throw new ExceptionInInitializerError(ex);          }      }          public static SessionFactory getSessionFactory() {          return sessionFactory;      } 
    So, in this above scenario, suppose if im giving the wrong password means exception should be caught and the string variable "GuigenserviceImpl.strAccpted" should be assigned to false.
    But im getting the SQL Exception only in console like wrong username and password. And finally i couldn't able to catch the exception in Sessions class, static block.
    Anyone can help me in catching that SQL Exception in my Sessions class and i need to handle that SQL Exception in my class.
    Im getting this following exception message in my console.
      INFO: configuring from resource: /hibernate.cfg.xml  Apr 6, 2009 2:47:00 PM org.hibernate.cfg.Configuration getConfigurationInputStream  INFO: Configuration resource: /hibernate.cfg.xml  Apr 6, 2009 2:47:00 PM org.hibernate.cfg.Configuration doConfigure  INFO: Configured SessionFactory: null  Apr 6, 2009 2:47:00 PM org.hibernate.connection.DriverManagerConnectionProvider configure  INFO: Using Hibernate built-in connection pool (not for production use!)  Apr 6, 2009 2:47:00 PM org.hibernate.connection.DriverManagerConnectionProvider configure  INFO: Hibernate connection pool size: 10  Apr 6, 2009 2:47:00 PM org.hibernate.connection.DriverManagerConnectionProvider configure  INFO: autocommit mode: false  Apr 6, 2009 2:47:00 PM org.hibernate.connection.DriverManagerConnectionProvider configure  INFO: using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@192.168.1.12:1521:orcl  Apr 6, 2009 2:47:00 PM org.hibernate.connection.DriverManagerConnectionProvider configure  INFO: connection properties: {user=scott, password=****}  Apr 6, 2009 2:47:01 PM org.hibernate.cfg.SettingsFactory buildSettings  WARNING: Could not obtain connection metadata  java.sql.SQLException: ORA-01017: invalid username/password; logon denied        at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)      at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:131)      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:204)      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:406)      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)      at oracle.jdbc.driver.T4CTTIoauthenticate.receiveOauth(T4CTTIoauthenticate.java:799)      at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:368)      at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:508)      at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:203)      at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)      at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:510)      at java.sql.DriverManager.getConnection(DriverManager.java:525)      at java.sql.DriverManager.getConnection(DriverManager.java:140)      at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)      at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)      at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2073)      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1298)      at com.beyon.ezygui.server.Sessions.<clinit>(Sessions.java:39)      at com.beyon.ezygui.server.GuigenserviceImpl.testRPC(GuigenserviceImpl.java:322)      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    Thanks in advance.
    Thanks & Regards,
    Kothandaraman N.

    Hi,
    Myself hardcoded that username and password checking like the below code.
    String name = loginData.get("userName").toString();
              String pswd = loginData.get("pswd").toString();
              String hstName = loginData.get("hName").toString();
              String prtNo = loginData.get("portNo").toString();
              String sid = loginData.get("sId").toString();
              SessionFactory sessionFactory = null;
              try {
                   if (name.trim().equals(userName) && pswd.trim().equals(password)
                             && hstName.trim().equals(hostName)
                             && prtNo.trim().equals(portNo) && sid.trim().equals(sId)) {
                        sessionFactory = Sessions.getSessionFactory();
                        strAccpted = "true";
                   } else {
                        strAccpted = "false";
              } catch (Exception e) {
                   e.printStackTrace();
                   strAccpted = "false";
              }I have my own values in string objects, then comparing that values with the values from login form. If both values are matching, then i will do configurations in hibernate.
    ResourceBundle resourceBundle = ResourceBundle
                   .getBundle("com.beyon.ezygui.server.Queries");
         public static final String connection_url = resourceBundle
                   .getString("connection.url");
         public static final String userName = resourceBundle.getString("userName");
         public static final String password = resourceBundle.getString("password");
         public static final String hostName = resourceBundle.getString("hostName");
         public static final String portNo = resourceBundle.getString("portNo");
         public static final String sId = resourceBundle.getString("sId");The above are the String objects i'm checking for the match with values from login form.
    Thanks & Regards,
    Kothandaraman N.

  • How to catching exceptions from another thread

    hi,guys,i have some code like this:
    public static void main(String[] args) {
    TimeoutThread time = new TimeoutThread(100,new TimeOutException("超时"));
         try{
         t.start();
         }catch(Exception e){
         System.out.println("eeeeeeeeeee");
    TimeoutThread will throws an exception when it runs ,but now i can't get "eeeeeeeeeee" from my console when i runs the main bolck code.so ,somebody help me ,thk.

    hi,ejp,this is my scene:
    getHttpParty(String name) is a method get some information from a web site,this maybe cause many times.now this method is called in my main(String args[]) method.
    i want to terminate getHttpParty if it runs 2s, can you give some simple code to do this.
    thank you very much.
    Edited by: user5449747 on 2010-11-17 上午12:03

  • How to catch Exception in a JSP

    Hi there,
    I'm building my first JSP application. I still don't know what happens to an exception thrown inside a scrptlet in a JSP page.
    My JSP page is resultados.jsp (it processes a DB query):
    <%@ page contentType="text/html; charset=iso-8859-1" language="java"
    import="java.lang.*,java.sql.*,pcliente.*" errorPage="error.jsp" session="true" %>
    <html>
    <head>
    <title>PCliente - Hist?rico de Mainframe</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body background="imagens/sm_bg.gif">
    <TABLE border=0 cellPadding=0 cellSpacing=0>
    <TR>
    <TD width=5><IMG alt="" height=1 src="imagens/pixel.gif" width=5></TD>
    <TD vAlign=top width=125><jsp:include page="menu.jsp" flush="true" /> </TD>
    <TD width=25><IMG alt="" height=1 src="imagens/pixel.gif" width=25></TD>
    <TD vAlign=top width=365>
    <%
    try
    PCliente pcliente = new PCliente(request.getParameter("maquina"),
                        request.getParameter("acessorio"),
                        request.getParameter("contrato"),
                        request.getParameter("estabelecimento"),
                        request.getParameter("ifiscal"));
    ResultSet rs = pcliente.executarQuery();
    while (rs.next())
    out.println("<BR>" + rs.getString("nome_estab_instalacao"));
    out.print(" -----" + rs.getString("num_serie_equipamento"));
    out.print(" -----" + rs.getString("num_contrato"));
    /*** SQL exception is thrown by pcliente.executarQuery() ***/
    catch (SQLException sqlEx)
    out.println("<P>" + "There was an error doing the query:");
    out.println ("<PRE>" + sqlEx + "</PRE> \n <P>");
    application.log("Exception lan?ada", sqlEx);
    throw new Exception(sqlEx.toString());
    finally
    out.println("<P>" + "FINALLY !!!");
    %>
    </TD>
    </TR>
    </TABLE>
    </body>
    </html>
    The error.jsp is
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*,pcliente.*" isErrorPage="true" session="true" %>
    <html>
    <head>
    <title>PCliente - Hist?rico de Mainframe - Erro</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <strong>Pagina de Erro</strong>
    </body>
    </html>
    The java class I'm using in this JSP is pcliente/PCliente with the source code:
    package pcliente;
    import java.sql.*;
    public class PCliente
    private String numSerieMaquina, numSerieAcessorio, numContrato, numEstabelecimento, ifiscal;
    private String strQuery;
    private Connection conn;
    private ResultSet rs;
    private Statement stmt;
    public PCliente(String numSerieMaquina, String numSerieAcessorio,
                        String numContrato, String numEstabelecimento,
                        String ifiscal)
    conn = null;
    rs = null;
    stmt = null;
    this.numSerieMaquina = numSerieMaquina;
    this.numSerieAcessorio = numSerieAcessorio;
    this.numContrato = numContrato;
    this.numEstabelecimento = numEstabelecimento;
    this.ifiscal = ifiscal;
    construirQuery();
    public ResultSet executarQuery() throws SQLException
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    /* This causes SQLException as a 'c' was taken from oracle in
    "jdbc:orale:oci8:@PROD" */
    conn = DriverManager.getConnection("jdbc:orale:oci8:@PROD","histmain", "histmain");
    stmt = conn.createStatement();
    rs = stmt.executeQuery(strQuery);
    return rs;
    private void construirQuery()
    strQuery = "SELECT num_serie_equipamento, num_contrato,
    nome_estab_instalacao" +
         " FROM anmpf04" +
         " WHERE 1 = 1";
    if (numSerieMaquina != null)
    if (numSerieMaquina.indexOf('%') == -1)
    strQuery += " AND num_serie_facturacao = " + numSerieMaquina;
    else     
    strQuery += " AND num_serie_facturacao LIKE '" + numSerieMaquina + "'";
    When I execute the JSP I see a page with the text FINALLY !!!
    But an exception was thrown and I can't,
    see
    out.println("<P>" + "There was an error doing the query:");
    out.println ("<PRE>" + sqlEx + "</PRE> \n <P>");
    in the jsp page
    application.log("Exception lan?ada", sqlEx);
    don't know where to find the log file
    throw new Exception(sqlEx.toString());
    isn't caught by the error page error.jsp
    What am I missing here ? a lot of stuff no doubt !
    Can anyone give me suggestion(s) on how to detect an Exception ?
    I would also apreciate a site with documentation regarding Exception processing inside JSP.
    Many thanks,
    MGoncalv

    Hi there,
    I'm building my first JSP application. I still don't
    know what happens to an exception thrown inside a
    scrptlet in a JSP page.I believe that any scriptlet exceptions get wrapped into a ServletException. At that time, if you have an errorPage defined for you JSP page, then it will go there. If you don't then the server will try to find the particular exception type in an <error-page> stanza in the web.xml. If it finds a mapping, it will go to that mapping, otherwise it will go to a default error page (container specific).
    A quick glance at your design shows some big problems though that you may or may not hit (depending on how often you hit the page in your testing). The primary one is that in your PCliente class, you are opening up database connections/statements/results sets w/o closing them. You will run out of connections/cursors at some point b/c of this. You need to do your reads from the database and then close those resources (in a finally block to make sure they get closed). Read the data in a lightweight java object that the JSP can use to actually get the data.
    Also, you only need to register the driver manager once. You can do this in static initialization block.
    ncuka

  • How to catch exception from shared library on Linux?

    Description:
    JNI dynamically loads shared library. Shared library throws exception (class CTestException). JNI can not catch it by CTestException name, only (...) works.
    My config:
    Linux RH AS 4 (x86 64)
    gcc: 3.4.5
    glib: 2.2.5
    Java 1.5.0_06
    g++ compiler options for JNI and shared libraries:
    g++ -Wl,-E -fPIC -shared ...
    There are multiple bugs on Java bugs database regarding C++ ABI incompatibility between Java binaries and stdc++ libraries linked with native code. But I could not find any conclusions on these bugs. Only plans/suggestions to recompile Java on new gcc. These bugs were quite old (regarding Java 1.3, 1.4). Now 1.6 is available but still there is same incompatibility. Maybe I am missing something and there is a way to fix this problem? Like to use specific gcc/glib versions for compilation? How people solve such problems? Any help is appreciated.

    It isn't any different; the commands are the same. You can find the exp executable in tehe $ORACLE_HOME/bin directory.

  • How to catch exception thrown by ActionBinding "Commit"

    I need a programmatic branch after the following line if an exception is thrown:
    ((JUCtrlActionBinding) panelBinding.findCtrlBinding("Commit")).invoke();
    I am building an ADFSwing application using JDev 10.1.3.
    I have a ViewObject derived from an EntityObject that I am trying to use for an insert.
    I have placed the line above in a try block with a "catch (JboException je)" block which includes the code I need to execute upon exception. A default error dialog appears when an exception is thrown "(oracle.jbo.AttrValException) JBO-27014: ...", but the catch block I have created is not executed.
    The effect is that a commit is not fulfilled, the default error dialog appears, but the program continues undaunted.
    I have included "setBundledExceptionMode(false)" just before the try block, but that doesn't make any difference.
    The commit statement above, and the try/catch block I've described are in a JUPanel.
    Any help on how and where I can catch an exception from the action binding is really appreciated!!

    You can use code like this:
         JUCtrlActionBinding commit = (JUCtrlActionBinding)panelBinding.findCtrlBinding("Commit");
         commit.invoke();
         if (!commit.getErrors().isEmpty()) {
           /* Error list not empty. Something went wrong. */
         }

Maybe you are looking for

  • Error deploying 10.1.3 application to App server 10.1.3

    Hi, I have an application (JSP, Struts, ADF BC) created in Jdev 10.1.3 and works fine on my local OC4J server. But when I deployed it to OAS 10.1.3, I got the following error: oracle.jbo.InvalidDefNameException: JBO-25004: Definition name view/DataBi

  • Daily Birthday campaign(Wishes)!!

    Hi Friends,                    i have a requirement to send birthday wishes to customers and employees automatically on daily basis using campaign automation. We used campaign automation process to send the wishes. when we release the campaign it exe

  • 3 xp boxes...one ubuntu...can NM let the Ubuntu box in on the fun?

    I have three XP boxes nicely networked with NM.  I have an Ubuntu box that I am trying to run Boxee on with the goal to see the XP box which has my media files.  I was able to get boxee to "see" my XP box by inputting its IP address, but it won't add

  • Publish Multiple Resource Calendars Superimposed To A Web Page

    Hi, I'm hoping you can assist. I have succeeded in publishing a resource calendar to a web page hosted on Exchange 2013. In the Outlook web client it is possible for a user to view multiple resource/room calendars superimposed. My question is; Is it

  • Message Header value is not written to DynamicConfiguration

    Hi Forum, I have a scenario on a PI 7.11 SP06, where a SOAP message is sent via HTTP to a SAP WAS Java. The response contains in header a  parameter"set-cookie" which has to be written in dynamic configuration. For example: Set-Cookie: JSESSIONID=DF4