Advertisement
Guest User

Untitled

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