jboss下的简单JSP与SERVLET应用部属

本文介绍如何在JBoss环境下部署简单的JSP页面及Servlet应用,包括创建JSP文件、WAR包制作、配置XML文件等步骤,并提供测试部署后的JSP与Servlet的方法。
jboss下的简单JSP与SERVLET应用部属
作者: 文章来源:
访问次数: 次 加入时间:2007-01-28
 

1. Write the JSP
Example (uno.jsp) :


java.util.*"%>



Date d = new Date();
String hoy = DateFormat.getDateInstance().format(d);
%>
La Fecha de hoy es :




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):


<?xml version="1.0" encoding="ISO-8859-1"?>

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:

<?xml version="1.0" encoding="ISO-8859-1"?>

br />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

<?xml version="1.0" encoding="ISO-8859-1"?>

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博客 ” ,链接:http://blog.itpub.net/9650775/viewspace-921917/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9650775/viewspace-921917/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值