This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to change php code to jsp

 
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: 65535
108
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.
 
Destiny's powerful hand has made the bed of my future. And this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!