[opencms-dev] why my struts demo working in tomcat but not in was

Huang Zhibin zbhuang2002 at hotmail.com
Fri Jun 23 05:42:22 CEST 2006


Hi list,
  I made one strut demo to test how to integrate struts app in opencms. Now 
it works on tomcat+mysql+jdk1.4, but not working on was+mysql+jdk1.4!? All 
files are the same. (It is very strange, right? ) So can anyone point out 
what I have done wrong? Any suggestions are appreciated! If you think what 
I did totally wrong, can you give me some suggestons about creating one 
simple struts demo in opencms?(I searched long time, but not very useful).
  I will describe what I did below.
  Copy struts tag files(struts-bean.tld/struts-html.tld/struts-logic.tld) 
in \opencms_war.ear\opencms.war\WEB-INF, and struts-config.xml and web.xml. 

  I also in opencms(http://localhost:8080/opencms/opencms/system/login) 
create one folder of "strutsTest", create two files(index.jsp and 
success.jsp) to test whether system can find action and implement it.

  Thanks again for your kindness.
Zhibin
-----------------------------
1. index.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<%
  response.setHeader("Cache-Control","no-store"); //HTTP 1.1
  response.setHeader("Pragma","no-cache"); //HTTP 1.0
  response.setDateHeader ("Expires", 0); //prevents caching at the proxy 
server
  response.addHeader("Cache-control", "max-age=0");
%>

<html:html>
  <head>
    <title>Hello - A first Struts program</title>
    <html:base/>
  </head>

  <body bgcolor="white"><p>
	<a href="/opencms/jump.do">testAction</a>
  </body>
</html:html>
-------------------------------
2. success.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<html:html locale="true">
  <head>
    <title>Hello - A first Struts program</title>
    <html:base/>
  </head>

  <body bgcolor="white"><p>
	success!!!
  </body>
</html:html>
------------------------------
3. struts-config.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>
  
  <action-mappings>
    <action path="/jump" forward="/opencms/strutsTest/success.jsp"> 
</action> 
  </action-mappings>

</struts-config>
--------------------------------
4. Content added in file of web.xml
  <!-- Struts Action Servlet Configuration  -->
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
	<init-param> 
      <param-name>debug</param-name> 
      <param-value>2</param-value> 
    </init-param> 
    <init-param> 
      <param-name>detail</param-name> 
      <param-value>2</param-value> 
    </init-param> 

     <load-on-startup>1</load-on-startup>
  </servlet>

  <!-- struts action-->
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>

  <!-- Struts Tag Library Descriptors -->
  <taglib>
    <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
  </taglib>
--------------------------------------------------------------





More information about the opencms-dev mailing list