Java Help

J-Buck

Member
Joined
Nov 12, 2009
Messages
230
Reaction score
0
Hi i was wondering if any one can help me out with my Java IT 108 project. If u wanna help just PM me. THanks!
 

nikfarjam

New Member
Joined
Aug 3, 2010
Messages
2
Reaction score
0
java pattern(shine enterprise patern)

Maplet (Web, MVC Framework)
What is Maplet?
Maplet is a framework for implementing web based program, which is compatible with MVC architecture. This framework is very easy and helpful for developers and analyzers to do their jobs better than before, let’s begin with a simple example.
First example
First you have to download shine library from one of these web sites:
www.j2os.org
Shine-Enterprise-Java-Pattern | Download Shine-Enterprise-Java-Pattern software for free at SourceForge.net
(file) 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>
////////////////////////

request page
(file) AddEmail.jsp
////////////////////////
<%@ page contentType="text/html;charset=windows-1252"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>untitled</title>
</head>
<body>
<DIV align="center">
<P>&nbsp;</P>
<P>
<STRONG><FONT size="5">Add a new Email to my email list</FONT></STRONG>
</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<form action="../../servlet/Model.Controller" method="get">
<DIV align="left">
<P>Name: &nbsp;
<input type="text" name="name"/>
</P>
<P>Email: &nbsp;
<input type="text" name="email"/></P>
<P>
<input type="submit" value="Submit"/>
<input type="reset" value="Reset"/>
</P>
</DIV>
</form>
</DIV>
</body>
</html>
///////////////////

request page
(file) SearchEmail.jsp
/////////////////////////
<%@ page contentType="text/html;charset=windows-1252"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>untitled</title>
</head>
<body>
<P>&nbsp;</P>
<P align="center">
<STRONG><FONT size="5">Search an email in my list</FONT></STRONG>
</P>
<P>&nbsp;</P>
<form action="../../servlet/Model.Controller" method="get">
<P>Name: &nbsp;
<input type="text" name="name"/>
</P>
<P>
<input type="submit" value="Submit"/>
<input type="reset" value="Reset"/>
</P>
</form>
</body>
</html>
/////////////////////////
request page
(file) AddPhoneNumber.jsp
////////////////////////////
<%@ page contentType="text/html;charset=windows-1252"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>untitled</title>
</head>
<body>
<DIV align="center">
<P>&nbsp;</P>
<P>
<STRONG><FONT size="5">Add a new phone to my phone book</FONT></STRONG>
</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<form action="../../servlet/Model.Controller" method="get">
<DIV align="left">
<P>Name: &nbsp;
<input type="text" name="name"/>
</P>
<P>phone num: &nbsp;
<input type="text" name="ph_num"/></P>
<P>
<input type="submit" value="Submit"/>
<input type="reset" value="Reset"/>
</P>
</DIV>
</form>
</DIV>
</body>
</html>
////////////////////
request page
(file) SearchPhoneNumber.jsp
////////////////////////////
<%@ page contentType="text/html;charset=windows-1252"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>untitled</title>
</head>
<body>
<P>&nbsp;</P>
<P align="center">
<STRONG><FONT size="5">Search a&nbsp;phone&nbsp;number in my phone book</FONT></STRONG>
</P>
<P>&nbsp;</P>
<form action="../../servlet/Model.Controller" method="get">
<P>Name: &nbsp;
<input type="text" name="name"/>
</P>
<P>
<input type="submit" value="Submit"/>
<input type="reset" value="Reset"/>
</P>
</form>
</body>
</html>
////////////////
response page
(file) EmailServiceResponses.jsp
//////////////////////////////////////
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="/WEB-INF/maplet.tld" prefix="maplet"%>
<maplet:Service name="add_success">Your email address had entered successfully.<br/>name:<br/><%=request.getParameter("name")%><br/>email:<br/><%=request.getParameter("email")%> </maplet:Service>
<maplet:Service name="search_success"><%=request.getParameter("name")%>'s email : <%=request.getParameter("email")%></maplet:Service>
<maplet:Service name="add_error">your email address failed! there was a problem!</maplet:Service>
<maplet:Service name="search_error">you had entered a wrong value!</maplet:Service>
<maplet:ErrorService>No Access!</maplet:ErrorService>
///////////////////////////////////////////////////////////

response page
(file) PhoneServiceResponses.jsp
/////////////////////////////////////
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="/WEB-INF/maplet.tld" prefix="maplet"%>
<maplet:Service name="add_success">Your phone number had entered successfully.<br/>name:<br/><%=request.getParameter("name")%><br/>phone:<br/><%=request.getParameter("ph_num")%> </maplet:Service>
<maplet:Service name="search_success"><%=request.getParameter("name")%>'s phone : <%=request.getParameter("ph_num")%></maplet:Service>
<maplet:Service name="add_error">your number failed! there was a problem!</maplet:Service>
<maplet:Service name="search_error">you had entered a wrong value!</maplet:Service>
<maplet:ErrorService>No Access!</maplet:ErrorService>
///////////////////////////////////

engine page (maplet)
(file) Controller.java
/////////////////////////////////
package Model;
import org.j2os.shine.maplet.*;
import org.j2os.shine.jconnection.JDBC;
import java.sql.*;
public class Controller extends Maplet {
public String name;
public String email;
public String ph_num;
private String forward_tag,forward_page;
JDBC db=new JDBC();

public void initialize() throws Exception{

db.login("com.mysql.jdbc.Driver","jdbc:mysql://localhost/j2os", "Username", "pass", true);

}

public void addEmail() throws Exception {
boolean a=db.executeSQLQuery("insert into email_table (name,email) values ('"+name+"','"+email+"')");
forward_page="../service/EmailServiceResponses.jsp";
if (a) {
forward_tag = "add_success";
} else {
forward_tag = "add_error";
}
}
public void searchEmail() throws Exception {
ResultSet r = db.getSQLQueryContent("select email from email_table where name like '"+name+"'");

while (r.next()) {
email= r.getString("email");
}
addURL("email",email);
forward_page="../service/EmailServiceResponses.jsp";
if (!(email.equals(""))) {
forward_tag = "search_success";
} else {
forward_tag = "search_error";
}
}
public void addPhoneNumber() throws Exception {
boolean a=db.executeSQLQuery("insert into phon_table (name,phone) values ('"+name+"','"+ph_num+"')");
forward_page="../service/PhoneServiceResponses.jsp";
if (a) {
forward_tag = "add_success";
} else {
forward_tag = "add_error";
}
}
public void searchPhoneNumber() throws Exception {
ResultSet r = db.getSQLQueryContent("select phone from phone_table where name like '"+name+"'");

while (r.next())
{
ph_num= r.getString("phone");
}
addURL("ph_num",ph_num);
forward_page="../service/PhoneServiceResponses.jsp";
if (!(ph_num.equals("")))
{
forward_tag = "search_success";
} else {
forward_tag = "search_error";
}
}

public void rater() throws Exception {
db.commit();
forward(forward_page, forward_tag);
}
}
//////////////////////////////////////////////////////
 

nikfarjam

New Member
Joined
Aug 3, 2010
Messages
2
Reaction score
0
java pattern(shine enterprise pattern)

JShooter (Reflect in Network Framework)
What is JShooter?
JShooter is a framework for distributing application programs on the network. Certainly, you have used RMI, Corba and JMS. Each of aforementioned technologies has its own special problems and at the same time enjoys extraordinary advantages. However, you must be careful about the expenses caused by these technologies. In most cases RMI, Corba and JMS increase the productions’ costs unbelievably. However in other cases they confuse programmers. Years ago, Reflect Oriented Programming was the focus of attention within professional programmers, then Aspect Oriented Programming came into the programming world but instead of reducing the programmer’s task, it causes the professional programmers and even the amateur ones to be confused in many cases. One of the most important capabilities of JShooter is that it makes the “Reflect Oriented Programming” easier to use.

file name:
==================================
<?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>
==================================

server side code
file name : Server.java
==================================
package ServerSide;
public class Server
{
//the definition of method lay here
public void PrintName(String Name)
{
System.out.print("Dear user Your name is "+Name);
System.out.print("<br>");
}
public int Plus(int val1,int val2)
{
int res = val1 + val2 ;
System.out.print(val1+" + "+val2+" is equal "+res+"");
System.out.print("<br>");
return res;
}
private void private_Method()
{
System.out.print("Peivate Method is invoked");
System.out.print("<br>");
}
}
==================================

Client side code
file name : Client.java
==================================
package ClientSide;
import ServerSide.Server;
import org.j2sos.shine.jshooter.*;
import java.util.ArrayList;
public class Client
{
//call the method from server side
//1- get method type
//2- invoke a method
//3- newInstat
//4- get fild type
public static void main(String arg[])throws Exception
{
ServerApplication Client_Obj = new Application().receive("Rokhsana","CommunityName");
Client_Obj.newInstance("ServerSide.Server");
ArrayList method_array = Client_Obj.getMethodsNames();
int i = 0;
while(method_array.size()!=i)
{
System.out.println(method_array.get(i));
i ++;
}
}
}
==================================

engine code on the server
file name : Core.java
==================================
package Engin;
import org.j2sos.shine.jshooter.Application;
public class Core
{
//distribute server class for client
public static void main(String arg[])throws Exception
{
Application distrubuted_Obj = new Application();
distrubuted_Obj.distribute(1099,"CommunityName");
System.out.print("~~~~~~~~~~Core isrunning~~~~~~~~~~~~~~");
}
}
==================================
 
Top