Jump to content

maplet vs. servleft


Guest lili

Recommended Posts

this is the code i take from j2os groupit works good but who to check if maplet Framework execution is faster then servlet ? :) maplet.tld

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"><taglib>  <tlibversion>1.0</tlibversion>  <jspversion>1.1</jspversion>  <shortname>maplet</shortname>  <tag>	<name>Service</name>	<tagclass>org.j2os.shine.maplet.tag.Service</tagclass>	<bodycontent>JSP</bodycontent>	<attribute>	  <name>name</name>	</attribute>  </tag>  <tag>	<name>SecureService</name>	<tagclass>org.j2os.shine.maplet.tag.SecureService</tagclass>	<bodycontent>JSP</bodycontent>	<attribute>	  <name>name</name>	</attribute>  </tag>  <tag>	<name>ErrorService</name>	<tagclass>org.j2os.shine.maplet.tag.ErrorService</tagclass>	<bodycontent>JSP</bodycontent>  </tag></taglib>

RequestPage.jsp

<%@ page contentType="text/html;charset=utf-8"%><html>  <head>	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">	<title>RequestPage</title>  </head>  <body>  <%  String error=request.getParameter("Error");  if(error==null){  error="";  }else{   out.print("<font face='tahoma' size='5' style='padding: 0;  font-weight:bold' dir='ltr' color='red'> PLZ Attention !!! Null Pointer Exception.</font>");    }  %>  <% request.setCharacterEncoding("utf-8"); %>   <form action="../enginecode" method="get" name="myform" >  </br></br>	<table dir="ltr" width="40%" border="0" bgcolor="Silver" align="center"><tr align="center" bgcolor="Yellow"> <td align="center" colspan="5"><font face="tahoma" size="2" dir="rtl" color="Black"><b>Request Page</b></font></td></tr><tr><td></br></td></tr>	  <tr>		<td><font face="tahoma" size="2" dir="ltr" color="Black">PlZ Your Name : </font></td><td colspan="4  "><font face="tahoma" size="2"  color="Black"><input type="TEXT" name="name" size="30" value="" maxlength="30" tabindex="1" style="font-family: Tahoma; font-size: 13; color: #800000"   /></font></td>	  </tr><tr><td><font face="tahoma" size="2" dir="ltr" color="Black">PlZ Your LastName : </font></td><td><font face="tahoma" size="2"  color="Black"><input type="TEXT" name="lastname" size="30" value="" maxlength="30" tabindex="2" style="font-family: Tahoma; font-size: 1em; color: #800000"   /></font></td></tr><tr> <td dir="ltr" align="center"  colspan="2">  <input type="SUBMIT" style="font-family: Tahoma; " tabindex="3" value="Submit" id="sabt" onclick="return checkfield(myform);" />    <input type="RESET" style="font-family: Tahoma; "  value="RESET"  />  </td>    </tr>  <tr><td></br></td></tr>	</table>	</form>	<script> 	window.focus();	myform.focus();	myform.name.focus();</script>  </body></html>

ResponsePage.jsp

<%@ page contentType="text/html;charset=utf-8"%><%@ page import="org.j2os.shine.jconnection.JDBC"%><%@ page import="java.sql.*"%><html>  <head>	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">	<title>RequestPage</title>  </head>  <body>  <% request.setCharacterEncoding("utf-8");   JDBC jconection=new JDBC();  %>   <form action="../enginecode" method="get" name="myform">  </br></br>	<table dir="ltr" width="40%" border="1" bgcolor="Silver" align="center"><tr align="center" bgcolor="Yellow"> <td align="center" colspan="5"><font face="tahoma" size="2" dir="rtl" color="Black"><b>Response Page</b></font></td></tr>	<tr><td align="center" colspan="3" bgcolor="#ccffcc"><b>MJDBTEST DataBase For This Project<b></td></tr><tr bgcolor="#99ccff">	<td align="center" width="50%">	<font face="tahoma" size="2" dir="ltr" color="Black"><b>Name</></font>	</td>	<td align="center" width="50%">	<font face="tahoma" size="2" dir="ltr" color="Black"><b>LastName</b></font>	</td></tr>	<%jconection.login("com.mysql.jdbc.Driver",				"jdbc:mysql://localhost:3306/MJDBTEST?useUnicode=true&characterEncoding=utf-8",				"ali", "ali", false);	ResultSet r=jconection.getSQLQueryContent("select * from userinfo"); 	while(r.next()){	%><tr>	<td align="center" >	<font face="tahoma" size="2" dir="ltr" color="Black"><%=r.getString("name")%></font>	</td>	<td align="center">	<font face="tahoma" size="2" dir="ltr" color="Black"><%=r.getString("lastname")%></font>	</td></tr>	<%}	jconection.commit();	%>	</table>	</form>  </body></html>

Engine.java

package j2os.maplet;import org.j2os.shine.jconnection.JDBC;import org.j2os.shine.maplet.Maplet;import java.sql.*;public class EngineCode extends Maplet {	public String name = "";	public String lastname = "";	JDBC jconection = new JDBC();	public void initialize() throws Exception {		jconection.login("com.mysql.jdbc.Driver",			"jdbc:mysql://localhost:3306/MJDBTEST?useUnicode=true&characterEncoding=utf-8",			"ali", "ali", false);	}	public void requestPage() throws Exception {		if (name.equals("") || lastname.equals("")) {			forward("Request/RequestPage.jsp?Error=404");			return;		}		jconection.executeSQLQuery(			"insert into userinfo (name,lastname) values('" + name + "','" +			lastname + "')");		forward("Response/ResponsePage.jsp");	}	public void rater() throws Exception {		jconection.commit();	}}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...