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

<script type="text/javascript"> google_ad_client = "pub-8800625213955058"; /* 336x280, 创建于 07-11-21 */ google_ad_slot = "0989131976"; google_ad_width = 336; google_ad_height = 280; // </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
 



1. Write the JSP

Example (uno.jsp) :





<%@ page import="java.text.*,

java.util.*"%>



&ltHTML>

&ltBODY>

<%

Date d = new Date();

String hoy = DateFormat.getDateInstance().format(d);

%>

La Fecha de hoy es :

&ltEM> <%= hoy %> </EM>

</BODY>

</HTML>



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"?>

&ltapplication>

&ltdisplay-name>uno</display-name>

&ltmodule>

&ltweb>

&ltweb-uri>uno.war</web-uri>

&ltcontext-root>/uno</context-root>

</web>

</module>

</application>



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%/server/default/deploy



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.4/catalina/common/lib/servlet.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"?>



<!DOCTYPE web-app

PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

"http://java.sun.com/dtd/web-app_2_3.dtd">

&ltweb-app>

&ltservlet>

&ltservlet-name>Dos</servlet-name>

&ltservlet-class>com.servlet.Dos</servlet-class>

</servlet>

</web-app>



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"?>

&ltapplication>

&ltdisplay-name>dos</display-name>

&ltmodule>

&ltweb>

&ltweb-uri>dos.war</web-uri>

&ltcontext-root>/dos</context-root>

</web>

</module>

</application>



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%/server/default/deploy



11. Run the JBoss-Tomcat server.



12. Test the Servlet. Use the following URL:



http://[IP ADDRESS SERVER]:8080/dos/servlet/Dos




       
       
      
      
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
原文:http://andy-li-chn.iteye.com/blog/1966986 公司的网站系统使用的中间是jboss7.1.1 Final,由于有些数据和服务测试环境不具备,免不了要在测试环境调试些jsp页面,发现从jboss社区里下载的jboss应用有个问题,新增jsp页面会实时部署,修改过的jsp页面就无法正常部署。 最新查到了如下解决方式: 在jboss7\standalone\configuration\standalone.xml文件中找到<subsystem xmlns="urn:jboss:domain:web:1.0" default-virtual-server="default-host">做如下配置 Xml代码 收藏代码 <subsystem xmlns="urn:jboss:domain:web:1.0" default-virtual-server="default-host"> <configuration> <jsp-configuration development="true"/> </configuration> <connector name="http" protocol="HTTP/1.1" socket-binding="http" scheme="http"/> <virtual-server name="default-host" enable-welcome-root="true"> <alias name="localhost"/> <alias name="example.com"/> </virtual-server> </subsystem> 以打开开发模式。但是加上该代码后,发现不起作用。后面有到jboss社区里翻了无数帖子,发现了Tomaz Cerar如下描述: in 7.1.1 we have included much reworked web subsystem but unfortunaly I missed a bit that coused all jsp configuration to be ignored. That bug was fixed soon after 7.1.1 was released and is now part of 7.1.2 and 7.2.x development branch. 原味连接https://community.jboss.org/message/723813由此可见这是一个本版本的bug,说是要在后期修复的。但是为中间升级风险很大,很多业务都是基于老版本的开发的,为了稳妥,我想肯定有人不用通过升级已经解决了此问题。 灯火阑珊处,发现了答案: 1. Please make sure to add <configuration> <jsp-configuration development="true"/> </configuration> in standalone.xml under <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false"> 2. Go to jboss-as-7.1.1.Final/modules/org/jboss/as/web/main Place the jboss-as-web-7.1.1.Final-RECOMPILE.jar in there. You can download from http://www.datafilehost.com/download-2cb9ff04.html 3. Open module.xml (jboss-as-7.1.1.Final/modules/org/jboss/as/web/main) and add the following line <!--resource-root path="jboss-as-web-7.1.1.Final.jar"/--> <resource-root path="jboss-as-web-7.1.1.Final-RECOMPILE.jar"/> 叙述的都很简单,我就不翻译了 原文详见:https://community.jboss.org/message/723945#723945#723945 按照作者所讲的方法操作了,问题奇迹般解决了,当时由于jboss核心包被重新编译过了,是否存在什么隐患还有待深入测试。 另在附件中提供了解决方案提供者重新编译过的包,我测试了是没问题。 现与大家分享。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值