954,554 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Move out java code from jsp



<%
String url = "jdbc:oracle:thin:@202.1.120.151:1921:ICUSTODY";
Connection con = DriverManager.getConnection(url,"app03admin","app03adminpwd");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from utility");//+ tableName );
String resStr = request.getParameter("result");
String tableName = request.getParameter("Table_name");
if(resStr == null){
%>






<%= lDisplayFormatter.format(appBundle,formName, "Utility.Utility") %>




<%= lDisplayFormatter.format(appBundle,formName, "Utility.Table_name") %>



<% optionValue= lFormatter.format((String)UtilityObj.get("Table_name"),locale) ;%>
<%= lDisplayFormatter.format(commonBundle,formName, "DefaultOption") %>

<%
String val = null;
while(rs.next()){
val= rs.getString("table_name");
%>
<%= val%>

<%

}
%>




<%} else if (resStr.equals("Y")) { Statement stmt1 = con.createStatement(); Statement stmt2 = con.createStatement(); ResultSet rs1 = stmt1.executeQuery("select * from "+ tableName ); ResultSetMetaData rsmd = rs1.getMetaData(); int noOfCols = rsmd.getColumnCount(); UtilityObj.put("txtTname",tableName); ResultSet rs2 = stmt2.executeQuery("select AUDIT_DATA from CMAPAUDIT where TABLE_NAME ='"+ tableName+"'" ); String auddet = ""; int ind = 0; int cnt_in = 0; int cnt_out = 0; String colkey = ""; String [] colarr = new String[100]; while(rs2.next()) { auddet = rs2.getString("audit_data"); while(auddet.indexOf(",")!=-1) { ind = auddet.indexOf(","); colkey = auddet.substring(0,ind); auddet = auddet.substring(ind+1); colarr[cnt_in]= colkey.trim(); %> <% cnt_in++; } cnt_out++; } %> <% String strColName =""; for(int i=1;i<=noOfCols;i++) { strColName = rsmd.getColumnName(i); for(int j=0;j <%=rsmd.getColumnName(i)%> <% } } } %> arr_bullet.gif<%= lDisplayFormatter.format(appBundle,formName, "Utility.OK") %>

<%
rs.close();
rs2.close();
stmt.close();
stmt2.close();
con.close();
}
%>




Soni_7
Newbie Poster
3 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

Read up about MVC architectures, JSTL, Servlet controllers, and things like that.
O'Reilly's JSP book is a good start (get the latest 3rd edition).

Don't get suckered into using Struts. It's an overly complex monstrosity, to which there are far better alternatives (the main reason it is still prominent is the fact that it was the first and thus has a large installed base).

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You