Buggy code:
public class SendNotificationEmail extends VelocityViewServlet { public Template handleRequest ( HttpServletRequest request , HttpServletResponse response , Context ctx ) { Template form = null ; Connection conn = null ; PreparedStatement ps = null ; PreparedStatement ps1 = null ; String sqluserName = "team152" ; String sqlpassword = "b042ba74" ; String url = "jdbc:mysql:////stusql.dcs.shef.ac.uk//team152" ; final String emailUsername = "info.team.master2@gmail.com" ; final String emailPassword = "team.master2" ; int rowcount = 0 ; String id = request . getParameter ( "articleId" ) ; try { Properties props = new Properties ( ) ; props . put ( "mail.smtp.auth" , "true" ) ; props . put ( "mail.smtp.starttls.enable" , "true" ) ; props . put ( "mail.smtp.host" , "smtp.gmail.com" ) ; props . put ( "mail.smtp.port" , "587" ) ; Session session = Session . getInstance ( props , new Authenticator ( ) { protected PasswordAuthentication getPasswordAuthentication ( ) { return new PasswordAuthentication ( emailUsername , emailPassword ) ; } } ) ; Class . forName ( "com.mysql.jdbc.Driver" ) . newInstance ( ) ; conn = DriverManager . getConnection ( url , sqluserName , sqlpassword ) ; String s = "select<seq2seq4repair_space>sr.ReaderId,<seq2seq4repair_space>sr.Email,<seq2seq4repair_space>k.Keyword<seq2seq4repair_space>from<seq2seq4repair_space>SubscribedReader<seq2seq4repair_space>sr<seq2seq4repair_space>left<seq2seq4repair_space>outer<seq2seq4repair_space>join<seq2seq4repair_space>SubscribedReaderKeyword<seq2seq4repair_space>srk<seq2seq4repair_space>on<seq2seq4repair_space>sr.ReaderId<seq2seq4repair_space>=<seq2seq4repair_space>srk.ReaderId<seq2seq4repair_space>left<seq2seq4repair_space>outer<seq2seq4repair_space>join<seq2seq4repair_space>ArticleKeyword<seq2seq4repair_space>ak<seq2seq4repair_space>on<seq2seq4repair_space>srk.KeywordId<seq2seq4repair_space>=<seq2seq4repair_space>ak.KeywordId<seq2seq4repair_space>left<seq2seq4repair_space>outer<seq2seq4repair_space>join<seq2seq4repair_space>Keyword<seq2seq4repair_space>k<seq2seq4repair_space>on<seq2seq4repair_space>k.KeywordId<seq2seq4repair_space>=<seq2seq4repair_space>ak.KeywordId<seq2seq4repair_space>left<seq2seq4repair_space>outer<seq2seq4repair_space>join<seq2seq4repair_space>Article<seq2seq4repair_space>a<seq2seq4repair_space>on<seq2seq4repair_space>a.ArticleId<seq2seq4repair_space>=<seq2seq4repair_space>ak.ArticleId<seq2seq4repair_space>where<seq2seq4repair_space>a.ArticleId<seq2seq4repair_space>=<seq2seq4repair_space>?" ; int i = 0 ; if ( ( request . getAttribute ( "EditionTitle" ) ) != null ) { ps = conn . prepareStatement ( "SELECT<seq2seq4repair_space>Email<seq2seq4repair_space>FROM<seq2seq4repair_space>SubscribedReader<seq2seq4repair_space>where<seq2seq4repair_space>ForthcomingEditions<seq2seq4repair_space>=<seq2seq4repair_space>1;" ) ; ResultSet results = ps . executeQuery ( ) ; if ( results . last ( ) ) { rowcount = results . getRow ( ) ; results . beforeFirst ( ) ; } String [ ] [ ] readerData = new String [ rowcount ] [ 1 ] ; while ( results . next ( ) ) { readerData [ i ] [ 0 ] = results . getString ( "Email" ) ; System . out . println ( readerData [ i ] [ 0 ] ) ; try { Message message = new javax . mail . internet . MimeMessage ( session ) ; message . setFrom ( new InternetAddress ( "info.team.master2@gmail.com" ) ) ; message . setRecipients ( TO , InternetAddress . parse ( readerData [ i ] [ 0 ] ) ) ; message . setSubject ( "Notification" ) ; message . setText ( ( ( "Dear<seq2seq4repair_space>reader,<seq2seq4repair_space>we<seq2seq4repair_space>just<seq2seq4repair_space>published<seq2seq4repair_space>a<seq2seq4repair_space>new<seq2seq4repair_space>edition:<seq2seq4repair_space>" + ( request . getAttribute ( "EditionTitle" ) ) ) + ",<seq2seq4repair_space>you<seq2seq4repair_space>can<seq2seq4repair_space>visit<seq2seq4repair_space>our<seq2seq4repair_space>website<seq2seq4repair_space>to<seq2seq4repair_space>read<seq2seq4repair_space>them" ) ) ; Transport . send ( message ) ; } catch ( MessagingException e ) { throw new RuntimeException ( e ) ; } i ++ ; } } ps1 = conn . prepareStatement ( s ) ; ps1 . setString ( 1 , id ) ; ResultSet results1 = ps1 . executeQuery ( ) ; if ( results1 . last ( ) ) { rowcount = results1 . getRow ( ) ; results1 . beforeFirst ( ) ; } String [ ] [ ] readerData1 = new String [ rowcount ] [ 3 ] ; i = 0 ; while ( results1 . next ( ) ) { readerData1 [ i ] [ 0 ] = results1 . getString ( "ReaderId" ) ; readerData1 [ i ] [ 1 ] = results1 . getString ( "Email" ) ; readerData1 [ i ] [ 2 ] = results1 . getString ( "Keyword" ) ; System . out . println ( ( ( ( ( ( readerData1 [ i ] [ 0 ] ) + "<seq2seq4repair_space>:<seq2seq4repair_space>" ) + ( readerData1 [ i ] [ 1 ] ) ) + "<seq2seq4repair_space>:<seq2seq4repair_space>" ) + ( readerData1 [ i ] [ 2 ] ) ) ) ; try { Message message = new javax . mail . internet . MimeMessage ( session ) ; message . setFrom ( new InternetAddress ( "info.team.master2@gmail.com" ) ) ; message . setRecipients ( TO , InternetAddress . parse ( readerData1 [ i ] [ 1 ] ) ) ; message . setSubject ( "Notification" ) ; message . setText ( ( ( "Dear<seq2seq4repair_space>reader,<seq2seq4repair_space>we<seq2seq4repair_space>just<seq2seq4repair_space>published<seq2seq4repair_space>a<seq2seq4repair_space>new<seq2seq4repair_space>article<seq2seq4repair_space>which<seq2seq4repair_space>included<seq2seq4repair_space>a<seq2seq4repair_space>keyword<seq2seq4repair_space>you<seq2seq4repair_space>have<seq2seq4repair_space>registered<seq2seq4repair_space>interest<seq2seq4repair_space>in:<seq2seq4repair_space>" + ( readerData1 [ i ] [ 2 ] ) ) + ",<seq2seq4repair_space>you<seq2seq4repair_space>can<seq2seq4repair_space>visit<seq2seq4repair_space>our<seq2seq4repair_space>website<seq2seq4repair_space>to<seq2seq4repair_space>read<seq2seq4repair_space>them" ) ) ; Transport . send ( message ) ; } catch ( MessagingException e ) { throw new RuntimeException ( e ) ; } i ++ ; } } catch ( Exception e ) { System . out . println ( e ) ; } finally { try { conn . close ( ) ; } catch ( SQLException e ) { e . printStackTrace ( ) ; } } try { request . getRequestDispatcher ( "//" ) . forward ( request , response ) ; } catch ( Exception e ) { <START_BUG> System . out . println ( ( "VelocityForm<seq2seq4repair_space>excpetion:<seq2seq4repair_space>" + e ) ) ; <END_BUG> } return form ; } }

Fix:
System . out . println ( ( "SendNotificationEmail<seq2seq4repair_space>excpetion:<seq2seq4repair_space>" + e ) ) ;