oggiemc 7 Junior Poster in Training

Hi people,

Im trying to handle an exception in my servlet by res.sendRedirect to another page..but it is not redirecting to the page i want, instead its going to a HTTP Staus 500 error page detailing the full stack trace..can someone tell me what might be wrong here, ive attached code..

Many thanks
oggiemc

import java.io.*; 
import java.lang.*; 
import java.sql.*; 
import javax.servlet.*; 
import javax.servlet.http.*; 
 
import javax.servlet.http.HttpServletResponse; 
 
import oracle.jdbc.driver.*; 
 
public class Manager2 {  
         
        Connection con = null; 
        Statement stmt = null; 
        PreparedStatement pstmt; 
        ResultSet rs = null; 
        String JDBCUrl = "jdbc:xxxxxxxxxxxxxx"; 
        String username = "xxxx"; 
        String password = "xxxx"; 
 
 
                 
        public void Register(String Username, String Password,  
                        String Surname, String Firstname, String Email, String Phone,  
                            PrintWriter out, HttpServletResponse res) throws IOException 
        { 
              String username = Username; 
              String password = Password; 
              String surname = Surname; 
              String firstname = Firstname; 
              String email = Email; 
              String phone = Phone; 
                 
                try 
                { 
                 
                pstmt = con.prepareStatement("INSERT INTO FMC_EMPLOYEE " + 
                                "(USERID,PASSWORD,SURNAME,FIRSTNAME,EMAIL,PHONE)VALUES(?,?,?,?,?,?)"); 
                  pstmt.clearParameters();        
                  pstmt.setString(1, username); 
                  pstmt.setString(2, password); 
                  pstmt.setString(3, surname); 
                  pstmt.setString(4, firstname); 
                  pstmt.setString(5, email); 
                  pstmt.setString(6, phone); 
                  pstmt.executeUpdate(); 
                                                                                                                                                                                                                    
                  pstmt.close(); 
 
                } 
                catch (Exception e) { 
                res.sendRedirect("/Fergal/EmployeeRegister.html"); 
  
            } 
                 
        } 
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.