• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to change php code to jsp  RSS feed

 
sarathd kumar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...
I need to change php code to jsp help me please....

Php code:


$line = $db->queryUniqueObject("SELECT * FROM supplier_details WHERE supplier_name='".$_POST['stock_name1']."'");
$address=$line->supplier_address;
$contact1=$line->supplier_contact1;
$contact2=$line->supplier_contact2;


$arr = array ("address"=>"$address","contact1"=>"$contact1","contact2"=>"$contact2");
echo json_encode($arr);


And My Jsp I am doing so far...

<%
Connection con = lm.Database.getConnection();
Statement st = con.createStatement();
String stock_name1=request.getParameter("stock_name1");
System.out.println("stock_name1-=="+stock_name1);
ResultSet rs = st.executeQuery("SELECT * FROM supplier_details WHERE supplier_name='"+stock_name1+ "'");
// ResultSet rs = st.executeQuery("SELECT name FROM supplier_details where name like '"+name+"%'");
if (! rs.next())
{
out.println("<h4>Sorry! Record Not Found!</h4>");
out.println("<p/> <a href='javascript:history.back()'>Back</a>");
return;
}
%>
<%
String address=rs.getString("supplier_address");
System.out.println("address-=="+address);
String contact1=rs.getString("supplier_contact1");
String contact2=rs.getString("supplier_contact2");
%>

Thanks For Advance...
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Modern JSPs (that is, any JSP written in the past 12 years) should have no Java code in them. Do your database access in Java classes in the model layer of the application, not in the JSP.

Proper Java web app structure is discussed in this article.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!