Guest User

SHOUBHIK BOSE

a guest
Feb 8th, 2011
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. <%@ page import="javax.servlet.http.HttpSession"%>
  2.  
  3. <%@ page import="javax.sql.*"%>
  4. <%@ page import="java.sql.*"%>
  5. <%@ page import="javax.naming.*"%>
  6.  
  7.  
  8.  
  9. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  10. pageEncoding="ISO-8859-1"%>
  11. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  12. <html>
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  15. <title>MESSAGE BOX</title>
  16. </head>
  17. <body>
  18. <h2> RECIEVED MESSAGES </h2>
  19.  
  20. <a name="a" href="/DEMO1/submitEmail.jsp">COMPOSE MESSAGE</a>
  21. <a name="a" href="/DEMO1/showMessage.jsp">RECIEVED MESSAGES</a>
  22. <a name="a" href="/DEMO1/showSentMessage.jsp">SENT MESSAGES</a>
  23.  
  24. <a></a>
  25. <%
  26. HttpSession hs=request.getSession(false);
  27. String uid=(String)hs.getAttribute("user_id");
  28. %>
  29.  
  30. The logged in user is: <%=uid %>
  31. <br><br><br>
  32. <table frame="box">
  33. <tr>
  34. <td>SUBJECT </td> <td> SENT BY </td> <td>SENT TO</td>
  35. <tr>
  36. <%
  37. Connection con = null;
  38. Statement stmt = null;
  39. try {
  40. Context initContext = new InitialContext();
  41. DataSource ds = (DataSource)initContext.lookup("java:comp/env/jdbc/DataSource");
  42. // Get a database connection
  43. con = ds.getConnection();
  44. }
  45. catch(java.lang.Exception e) {
  46. e.printStackTrace();
  47. System.err.print(e.getClass().getName());
  48. System.err.println(e.getMessage());
  49. }
  50.  
  51. try{
  52. stmt = con.createStatement();
  53.  
  54. ResultSet rs=stmt.executeQuery("SELECT MESSAGE_DETAILS.OPENED, MESSAGE_DETAILS.MESSAGE_ID, MESSAGE_DETAILS.SENDEE_ID, MESSAGE_DETAILS.SENDER_ID, MESSAGE_DETAILS.SUBJECT, MESSAGE_DETAILS.MESSAGE_ID FROM SHOUBHIK.MESSAGE_DETAILS AS MESSAGE_DETAILS WHERE MESSAGE_DETAILS.SENDEE_ID = "+uid);
  55.  
  56. while (rs.next()) {
  57. %>
  58.  
  59.  
  60. <tr>
  61. <td><a target="iframe_a" name="a" href="/DEMO1/showBody.jsp?mid=<%=rs.getString("message_id")%>"><%=rs.getString("subject")%> </a></td>
  62. <td><%= rs.getString("sender_id") %></td>
  63. <td><%= rs.getString("sendee_id") %></td>
  64. </tr>
  65.  
  66. <%
  67. }
  68.  
  69. rs.close();
  70. stmt.close();
  71. con.close();
  72. }
  73.  
  74. catch(Exception e){
  75.  
  76. e.printStackTrace();
  77. System.err.print(e.getClass().getName());
  78. System.err.println(e.getMessage());
  79.  
  80. }
  81. stmt.close();
  82. con.close();
  83.  
  84. %>
  85.  
  86. </table>
  87. <br><br><br>
  88. <iframe src="/DEMO1/showMessage.jsp" name="iframe_a" width="700"></iframe>
  89. </body>
  90. </html>
Advertisement
Add Comment
Please, Sign In to add comment