--------------------------------------------------------------- 1) TITLE : ASP, PHP, JSP Mapping Table 2) DATE : 2002.09.17 3) ABSTRACT : 4) FILE NAME : asptophptojsp.txt 5) REL. FILE NAME : 6) REFERENCE : 7) DOC, HISTORY : 2002.09.17 Creation 8) COPYRIGHT : muralimedisetti@yahoo.com ---------------------------------------------------------------- ---------------------------------------------------------------- NO. ASP ,PHP, JSP ---------------------------------------------------------------- 0. Script Tag ASP : <% ..... %> PHP : JSP : <%@ page language="java" %> <% ..... %> 1. Redirect URL ASP : <% Response.Redirect(url) %> PHP : "); exit; ?> Or Using com function JSP : 2. Include File ASP : PHP : JSP : <%@ include file="include/include_com.jsp" %> 3. Refer SELF URL ASP : NONE PHP : JSP : NONE 4. Request ASP : user_id = Request("user_id") PHP : direct using $user_id JSP : String user_id = request.getParameter("user_id"); 5. Session to Cookie ASP : Session("user_id") = user_id PHP : No Session. Instead using cookie. JSP : HttpSession session = request.getSession(ture); String str = (String)session.getValue(session.getId()); if (str == null) { str = "Session Value"; session.putValue(session.getId(), str); } 6. Cookie ASP : If Request.Cookies("login") = "" Then Response.Cookies("login")=login_id Response.Cookies("login").Expires=Date+120 End If PHP : (Inform: You set the cookie in the first line of your page.) (Inform: You set the cookie with different name.) setcookie("user_id","$user_id","now()+3600","/"); setcookie("user_id","$user_id","time()+0","/"); //Release Cookie JSP : Cookie[] cookies = request.getCookies(); for (int i=0; i < cookies.length; i++) { if (cookies[i].getName() == "login") { if (cookie[i].getValue() == null) { Cookie loginCookie = new Cookie("login", user_id); loginCookie.setDomain(url); loginCookie.setPath("/"); response.addCookie(loginCookie); } } } 6. DB Connection ASP : Sub DB_Connection(conn) Set conn = Server.CreateObject("ADODB.Connection") conn.ConnectionTimeout = 60 conn.CommandTimeout = 60 conn.Open "jinybbs", "jinybbs", "" '** ConnectionString, UserID, Password End Sub PHP : function DB_Connection() { $conn = mysql_connect("localhost","jinybbs","") or die("Error: Can't connect to the DB Server"); mysql_select_db("jinybbs", $conn); return $conn; } JSP : import java.sql.*; Connection DB_Connection() throws ClassNotFoundException, SQLException { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection("jdbc:odbc:jinybbs","jinybbs",""); return conn; } 7. Query Result RecordSet ASP : Sub SelectADMIN_Owner(conn, table_owner,is_admin, rs) sqlstr = " SELECT * FROM ADMIN " If table_owner <> "*" Then sqlstr = sqlstr + " WHERE table_owner = '"+table_owner+"' " End If If is_admin = "Y" Then sqlstr = sqlstr + " AND is_admin = 'Y' " End If sqlstr = sqlstr + " ORDER BY table_id " Set rs = Server.CreateObject("ADODB.RecordSet") rs.CursorType = 3 rs.Open sqlstr, conn End Sub PHP : function SelectADMIN_Owner($conn, $table_owner,$is_admin) { $sqlstr = " SELECT * FROM admin " ; if ($table_owner != "*") $sqlstr = $sqlstr." WHERE table_owner = '$table_owner' "; if ($is_admin == "Y") $sqlstr = $sqlstr." AND is_admin = 'Y' "; $sqlstr = $sqlstr." ORDER BY table_id "; $result = mysql_query($sqlstr) or die("Error: Not Good Query Statement: ".mysql_error()); return $result; } JSP : ResultSet SelectADMIN_Owner(Connection conn, String table_owner) throws SQLException { Statement stmt = conn.createStatement(); String sqlstr = " SELECT * FROM admin " ; ResultSet rs = stmt.executeQuery(sqlstr,TYPEFORWARD_ONLY); (or TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE) return (rs==null)?null:rs; } 8. Multiple RecordSet Fetch ASP : <% Do While Not rs.EOF %> <% If rs("is_admin") = "N" Then %>