• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

facing a problem

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
brevity is the soul of wit - shakepeare. Tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!