Advertisement
Guest User

Untitled

a guest
Oct 6th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.19 KB | None | 0 0
  1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  2. pageEncoding="ISO-8859-1"%>
  3. <%@ taglib prefix="s" uri="/struts-tags"%>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  5. <html>
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  8. <title>Insert title here</title>
  9. </head>
  10. <body>
  11. <s:form action="details.action">
  12.  
  13. <s:submit value="getresponse" align="center" />
  14. </s:form>
  15. </body>
  16. </html>
  17.  
  18. <package name="getdetails" extends="struts-default">
  19. <action name="details" class="com.viewdetails">
  20. <result name="success">/viewdetails.jsp</result>
  21.  
  22. </action>
  23.  
  24. package com;
  25.  
  26. import java.util.ArrayList;
  27.  
  28. public class viewdetails{
  29.  
  30. public String firstname,lastname,teamname,reply;
  31.  
  32.  
  33. public String getFirstname() {
  34. return firstname;
  35. }
  36.  
  37.  
  38. public void setFirstname(String firstname) {
  39. this.firstname = firstname;
  40. }
  41.  
  42.  
  43. public String getLastname() {
  44. return lastname;
  45. }
  46.  
  47.  
  48. public void setLastname(String lastname) {
  49. this.lastname = lastname;
  50. }
  51.  
  52.  
  53. public String getTeamname() {
  54. return teamname;
  55. }
  56.  
  57.  
  58. public void setTeamname(String teamname) {
  59. this.teamname = teamname;
  60. }
  61.  
  62.  
  63. public String getReply() {
  64. return reply;
  65. }
  66.  
  67.  
  68. public void setReply(String reply) {
  69. this.reply = reply;
  70. }
  71.  
  72.  
  73. public String execute() {
  74.  
  75.  
  76.  
  77. getAction n1=new getAction();
  78.  
  79. String a=n1.getresult(this);
  80.  
  81.  
  82. System.out.println("the value of a is:"+a);
  83. return a;
  84.  
  85.  
  86. }
  87.  
  88. package com;
  89.  
  90. import java.sql.Connection;
  91. import java.sql.DriverManager;
  92. import java.sql.PreparedStatement;
  93. import java.sql.ResultSet;
  94. import java.util.ArrayList;
  95.  
  96. import com.opensymphony.xwork2.ActionSupport;
  97.  
  98. public class getAction extends ActionSupport{
  99.  
  100.  
  101. public ArrayList<viewdetails> list=new ArrayList<viewdetails>();
  102.  
  103. public ArrayList<viewdetails> getList() {
  104. return list;
  105. }
  106. public void setList1(ArrayList<viewdetails> list) {
  107. this.list = list;
  108. }
  109.  
  110.  
  111. public String getresult(viewdetails r)
  112. {
  113. try{
  114. Class.forName("oracle.jdbc.driver.OracleDriver");
  115. Connection con=DriverManager.getConnection(
  116. "jdbc:oracle:thin:@localhost:1521:xe","sanjeev","sanjeev");
  117.  
  118. PreparedStatement ps=con.prepareStatement("select d.firstname, d.lastname,d.teamname,e.reply from newuser d INNER JOIN teamdetails e ON d.emailid = e.emailid ");
  119. ResultSet rs=ps.executeQuery();
  120.  
  121. while(rs.next()){
  122. viewdetails view=new viewdetails();
  123. view.setTeamname(rs.getString("teamname"));
  124. view.setFirstname(rs.getString("firstname"));
  125. view.setLastname(rs.getString("lastname"));
  126. view.setReply(rs.getString("reply"));
  127. list.add(view);
  128.  
  129. System.out.println(rs.getString("teamname"));
  130. System.out.println(rs.getString("firstname"));
  131. System.out.println(rs.getString("lastname"));
  132. System.out.println(rs.getString("reply"));
  133.  
  134.  
  135.  
  136. }
  137.  
  138. con.close();
  139. }
  140.  
  141. catch(Exception e)
  142. {
  143. e.printStackTrace();
  144. }
  145.  
  146. return "success";
  147.  
  148. }
  149.  
  150. }
  151.  
  152. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  153. pageEncoding="ISO-8859-1"%>
  154. <%@ taglib prefix="s" uri="/struts-tags"%>
  155. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  156. <html>
  157. <head>
  158. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  159. <title>Insert title here</title>
  160. </head>
  161. <body>
  162. <center><h3>get response:</h3> </center>
  163.  
  164.  
  165.  
  166. Welcome to see the response
  167. <table>
  168. <s:iterator var="i" step="1" value="list" >
  169.  
  170.  
  171. <tr>
  172. <td width="10%"><s:property value="%{teamname}"/></td>
  173. <td width="10%"><s:property value="%{firstname}" /></td>
  174. <td width="10%"><s:property value="%{lastname}" /></td>
  175. <td width="20%"><s:property value="%{emailid}" /></td>
  176. <td width="20%"><s:property value="%{reply}"/></td>
  177.  
  178.  
  179.  
  180. </tr>
  181.  
  182. </s:iterator>
  183.  
  184.  
  185.  
  186.  
  187. </table>
  188.  
  189. </body>
  190. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement