| jboss下的简单JSP与SERVLET应用部属 |
作者: 文章来源: 访问次数: 次 加入时间:2007-01-28 |
|
1. Write the JSP Example (uno.jsp) :
<%@ page import="java.text.*, java.util.*"%>
<% Date d = new Date(); String hoy = DateFormat.getDateInstance().format(d); %> La Fecha de hoy es : <%= hoy %>
2. Create a WAR file with JSP file. Use the following command :
jar -cvfM uno.war uno.jsp
3. Create an application.xml file in META-INF directory. You need set the correct values in tag and tag.
web-uri = WAR name file
Example (application.xml):
uno
uno.war /uno
4. Create a EAR file with WAR file and application.xml file. Use the following command :
jar -cvfM uno.ear uno.war META-INF
5. Copy this EAR file in %JBOSS_HOME%serverdefaultdeploy
6. Run the JBoss-Tomcat server.
7. Test the JSP. Use the following URL:
http://[IP ADDRESS SERVER]:8080/uno/uno.jsp
The first time is slow because JBoss-Tomcat compiles the JSP file but the next time is fast.
HERE IS THE PROCEDURE FOR SERVLETS :
1. Write your servlet. For example
Dos.java
package com.servlet;
import java.io.*; import javax.servlet.*; import javax.servlet.http.*;
public class Dos extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter(); out.println("Hello World"); } }
2. Compile your servlet. Use the following command :
javac -classpath d:jboss-3.0.1_Tomcat-4.0.4catalinacommonlibservlet.jar Dos.java
3. Create a WEB-INF directory.
4. Create a classes directory in WEB-INF directory and copy Dos.class.
WEB-INF (Subdirectory) I I classes (Subdirectory) --- I I com (subdirectory)---- I I servlet (subdirectory) I I Dos.class (Java Class)
5. Create a web.xml file in WEB-INF directory.
For example:
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
Dos com.servlet.Dos
6. Create a META-INF directory.
7. Create an application.xml file in META-INF directory.
For example:
application.xml
dos
dos.war /dos
8. Create a WAR file. Use the following command :
jar -cvfM dos.war WEB-INF
9. Create a EAR file. Use the following command :
jar -cvfM dos.ear dos.war META-INF
10. Copy the EAR file in %JBOSS_HOME%serverdefaultdeploy
11. Run the JBoss-Tomcat server.
12. Test the Servlet. Use the following URL:
http://[IP ADDRESS SERVER]:8080/dos/servlet/Dos
|
| |
[@more@]
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9650775/viewspace-921917/
,如需转载,请注明出处,否则将追究法律责任。