Announcement Announcement Module
Collapse
No announcement yet.
create a HelloWorld with Maplet Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • create a HelloWorld with Maplet

    Maplet is a framework for implementing web based program, which is compatible with MVC architecture.
    • - Each Servlet must inherit from Maplet class.
    • - Each Servlet has two fixed methods and number of variable ones. Fixed methods are “initialize” and “rater”, variable methods are those which named like page name.
    • - Variable methods are named exactly same as the name of request pages, the only difference is that they start with small letters.
    The invocation process of methods is as follows:
    1- initialize()
    2- page_Name_Method()
    3- rater()

    Considered that you can have several page_Name_Method() in one maplet.So you dont have to make a special maplet for each jsp.It means your project will be shorter and cleaner and manageable.
    To create a maplet you need to download and add Shine enterprise pattern to your project.

    lets back to our helloWorld :
    1- first of all you need to download and add shine enterprise pattern to your project.
    2- create a File that called maplet.tld and put it near your web.xml
    its context is constant as bellow:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE taglib PUBLIC "-//Sun Microsysems, 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>name<\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.Service<\tagclass>
        <bodycontent>JSP<\bodycontent>
        <attribute>
          <name>name<\name>
        <\attribute>   
      <\tag>
      <tag>
      <name>ErrorService<\name>
       <tagclass>org.j2os.shine.maplet.tag.Service<\tagclass>
        <bodycontent>JSP<\bodycontent>
        <attribute>
          <name>name<\name>
        <\attribute>   
      <\tag>
    <\taglib>
    3- create a sevlet that called Validation.java and change its code as bellow:
    Code:
    import view;
    import org.j2os.shine.maplet.Maplet;
    
    public class Validation extends Maplet
    {
     
      public void initialize() throws Exception
      {
        out.println("Initialize Method was run");
        out.print("<br>");
        //super.init(config);
      }
    
      public void helloWorld()throws Exception
      {
        out.println("HelloWorld Method was run");
        out.print("<br>");
      }
      public void rater()throws Exception
      {
        out.println("rator Method was run");
        out.print("<br>");
      }
    }
    4- create a jsp file and call it HelloWorld.jsp ,put a form and a submit button into and set the "action" of the form to "servlet/view.Validation"
    5- run the jsp and hello world is ready!!!
Working...
X