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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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']."'");

$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");
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 (!
out.println("<h4>Sorry! Record Not Found!</h4>");
out.println("<p/> <a href='javascript:history.back()'>Back</a>");
String address=rs.getString("supplier_address");
String contact1=rs.getString("supplier_contact1");
String contact2=rs.getString("supplier_contact2");

Thanks For Advance...
Bear Bibeault
Author and ninkuma
Posts: 65535
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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!