Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JSP and the fly likes facing a problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "facing a problem" Watch "facing a problem" New topic
Author

facing a problem

kandarp Bhatt
Greenhorn

Joined: Aug 03, 2001
Posts: 13
Friends,
I am facing a problem, when i run this code It will not work. it is just show blank page.
Thanks in advance
kandarp
***This is test.jsp
<jsp:useBean id="sdb" scope="page" class="common.SupportDB"/>
<link rel="stylesheet" type="text/css" href="style.css">
<html>
<head>
<title>Gujarat Print Pack</title>
</head>
<body>
<%
String hold_user = request.getParameter("id");
String hold_str1 = request.getParameter("str");
String hold_id = request.getParameter("D1");

int hold_str = Integer.parseInt(hold_str1);

if(hold_id=="OrderID"){
if(sdb.IsValidRecord("Orders", "OrderID",hold_str)){
%>
<jsp:forward page="MainOrderDetails.jsp">
<jsp aram name="orderid" value="<%=hold_str%>"/>
</jsp:forward>
<%
}
%>
<%=hold_str%> Not Found.
<%
}

if(hold_id=="JobID"){
if(sdb.IsValidRecord("JobName", "JobNameID", hold_str)){
%>
HELLO HOW ARE YOU???
<jsp:forward page="MainJobDetails.jsp">
<jsp aram name="jobid" value="<%=hold_str%>"/>
</jsp:forward>
<%
}
%>
<%=hold_str%> Not Found.
<%
}

%>
There is some Error............
</body>
</html>
***** JAVA Bean
package common;
import common.*;
import java.sql.*;
import java.util.*;
public class SupportDB{
private Connection con;
private Statement st;
private ResultSet rs;
public void getConnection(){
try{
Class.forName ("org.gjt.mm.mysql.Driver");
con=DriverManager.getConnection("jdbc:mysql:///gujarat_gpp?user=gujarat&password=gck007&autoReconnect=true");
}catch(Exception e){
System.out.println("SupportDB - getConnection() : ");
e.printStackTrace();
}
} // getConnection(), method
public boolean IsValidRecord(String TableName, String srchField, int hold_str){
boolean result = false;
String retVal = null;
try{
getConnection();
st=con.createStatement();
String qry = "select * from "+TableName+" where "+srchField+" = "+hold_str;
rs=st.executeQuery(qry);
if(rs.next()){
retVal = rs.getString(srchField);
if(Integer.parseInt(retVal)==hold_str){
result=true;
}
}
rs.close();
st.close();
con.close();
}catch(Exception e){
System.out.println("SupportDB - boolean IsValidRecore() : ");
e.printStackTrace();
}
return result;
}//end of public boolean IsValidRecore()
} // SupportDB, class
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi Kandarp,
i noticed one thing in your code,
if(hold_id=="OrderID")
well, string comparisions can't be done in this manner and thats why the execution doesn't follow the path you expect it to...
you should use hold_id.equals("OrderID") ...
try that and let me know if it solves your problem..
regards
maulin
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: facing a problem