建立ejb各个接口和bean的文件

发表于:2007-07-01来源:作者:点击数: 标签:
%@page contenttype=text/html;charset=gb2312% %@page import= java .io.*% % try { String ejb_type=request.getParameter(ejb_type); String ejb_name=request.getParameter(ejb_name); File myFile=new File(ejb_name); myFile.mkdir(); myFile=new File(
<%@page contenttype="text/html;charset=gb2312"%>
<%@page import="java.io.*"%>
<%
try
{
    String ejb_type=request.getParameter("ejb_type");
    String ejb_name=request.getParameter("ejb_name");
    
    File myFile=new File(ejb_name);
    myFile.mkdir();
    myFile=new File(ejb_name+"//"+ejb_name+"Home.java");
    myFile.createNewFile();
    myFile=new File(ejb_name+"//"+ejb_name+"Remote.java");
    myFile.createNewFile();
    myFile=new File(ejb_name+"//"+ejb_name+"EJB.java");
    myFile.createNewFile();
    %>
    <html>
    <body>

    <script language="javascript">
    function err(form)
    {
        return true;
    }
    function stringFilter(strFilter)
    {
        for (i=0;i<strFilter.length;i++)
        {
            if((strFilter.charAt(i)>="A" && strFilter.charAt(i)<="Z")||(strFilter.charAt(i)>="a"&&strFilter.charAt(i)<="z")||(strFilter.charAt(i)>="0"&&strFilter.charAt(i)<="9")||(strFilter.charAt(i)=="_"))
            {}
            else
            {
                window.alert ("您的输入中有非法字符");
                return 1;
            }
        }
        return 0;
    }
    </script>

    <center>
    <form action="createfile.jsp?ejb_type=<%=ejb_type%>&ejb_name=<%=ejb_name%>&server_type=<%=request.getParameter("server_type")%>" method="post" name="form1" onsubmit="return err(form1)">
    <table border="1" width="700">
        <tr>
            <td align="right" width="300">
                请输入您要将它创建的包名:
            </td>
            <td align="left" width="400">
                <INPUT TYPE="text" NAME="package_name">
            </td>
        </tr>

        <%if (ejb_type.equals("entity"))
        {%>
            <tr>
                <td align="right" width="300">
                    请输入您要创建的Entity Bean的主键类型:
                </td>
                <td align="left" width="400">
                    <SELECT NAME="primaryKey">
                        <option value="String">String</option>
                        <option value="Integer">Integer</option>
                        <option value="Long">Long</option>
                        <option value="Float">Float</option>
                        <option value="Date">Date</option>
                    </SELECT>
                </td>
            </tr>
        <%}%>

        <tr>
            <td align="right" width="300">
                请输入您要创建的Home接口中的方法:
                <br><font color="red">(请先写方法名称,空格后输入返回类型;以回车来分割不同方法)</font>
            </td>
            <td align="left" width="400">
                <%if (ejb_type.equals("entity"))
                {%>
                    <TEXTAREA NAME="Home_method" ROWS="4" COLS="50">create() <%=ejb_name+"Remote"%>
findByPrimaryKey() <%=ejb_name+"Remote"%></TEXTAREA>
                <%}else{%>
                    <TEXTAREA NAME="Home_method" ROWS="4" COLS="50">create() <%=ejb_name+"Remote"%></TEXTAREA>
                <%}%>
            </td>
        </tr>

        <tr>
            <td align="right" width="300">
                请输入您要创建的Remote接口中的方法:
                <br><font color="red">(请先写方法名称,空格后输入返回类型;以回车来分割不同方法)</font>
            </td>
            <td align="left" width="400">
                <TEXTAREA NAME="Remote_method" ROWS="4" COLS="50"></TEXTAREA>
            </td>
        </tr>

        <tr>
            <td colspan="2" align="center"><INPUT TYPE="submit" value="提交">   <INPUT TYPE="reset" value="重填"></td>
        </tr>
    </table>
    <form>
    </center>

    </body>
    </html>
    <%
}
catch(Exception e)
{
    out.print(e.getMessage());
}%>

这个文件是createejb.jsp。主页面是index.jsp 

原文转自:http://www.ltesting.net