jsp - How to stop getting error report in Tomcat -


i created jsp page test how connect oracle, using code.

  string conn_string = "jdbc:oracle:thin:@localhost:1521:orcl";      try {         class.forname("oracle.jdbc.driver.oracledriver");     } catch (classnotfoundexception e) {         e.printstacktrace();     }     connection conn = drivermanager.getconnection(conn_string,             "ums", "d0801213177"); 

when happens such oracle initializing or tns refusing take more connection or password of database changed then, error report when load page. displays total connection string. if happens when user using page security lost.

so, question is there way stop tomcat form reporting errors?". if there better way please tell.

follow up: if using prepared statements, errors table/view doesn't exists these types of errors general need put each block in separate try catch blocks?

edit

as beginer, struggling hide stacktrace because showing connection string, username, password too.

now know should have never written code in jsp in first place. using servlet task have been better

jsp gives option specify error page each jsp. whenever page throws exception, jsp container automatically invokes error page.

<%@ page language="java"  errorpage="" %> <html> <head> <title>error handling try catch block in jsp</title> </head>  <body> <% try{      string conn_string = "jdbc:oracle:thin:@localhost:1521:orcl";      try {         class.forname("oracle.jdbc.driver.oracledriver");     } catch (classnotfoundexception e) {         e.printstacktrace();     }     connection conn = drivermanager.getconnection(conn_string,         "ums", "d0801213177"); } catch(exception e) {   e.printstacktrace();   out.print("error caught catch block : "+e.getmessage()); } %> </body> </html> 

preferably business logic inside servlet , redirect using requestdispatcher jsp.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -