簡體   English   中英

JSP的Eclipse / JBoss部署

[英]Eclipse/JBoss Deployment of a JSP

好吧,我要在這里提出全部shot彈槍問題。 我嘗試使用Eclipse SR2在JBoss 6.0服務器上創建基本的JSP。 我下面有一個JSP文件,一個Web.XML和Build.XML。 現在只需記住Eclipse將WAR存儲在C:\\ JBoss \\ jboss-6.0.0.Final \\ server \\ default \\ deploy \\ quote.war

問題是文件沒有出現在本地主機上。 我試圖弄清楚這個問題。

所以這是quote.jsp:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Arrays" %>
<%@ page import="java.util.Random" %>

<%
//Word up.
String[] quotes = {
"Eat my shorts!", "Cowabunga dude!","Oh snap!","Psyche!",
"Talk to the hand!","Different strokes for different folks.",
"Dont go there.","Da Bomb!",
"All that, and a bag of potato chips!"};

ArrayList<String> list = new ArrayList<String>(Arrays.asList(quotes));
Random r = new Random(); /*This creates a new random number generator.*/
int x = r.nextInt(list.size()); /*nextInt finds the next integer of the randomized number, between 0 and the integer provided, in this case, nine possible phrases.*/
String saying = (String)list.get(x); //Not sure why they felt they had to cast this as a string...
pageContext.setAttribute("saying",saying); /*Apparently takes whatever string value to be used within the scope of the HTML?*/
%>

<html>
<head>
<title>Behold! And Despair!</title>
</head>
<body>
<br>
<c:set var="sessionCount" scope="session"
value="${sessionCount +1}" />
<c:set var="applicationCount" scope="application"
value="${applicationCount +1}" />
<h1>
<font color="#1230cb">Catchphrases You Wish Time Forgot</font>
</h1>
<h3>
<br>
<font color="#a6a6a6">
${saying}
<br>-your Childhood
</font>
</h3>
<br><br>
You've visited this application ${sessionCount}
times this session. Perhaps its time to get a life.
<br>
Also, this application has been visited ${applicationCount}
by you and others who also have no social outlet.
</body>
</html>

這是web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/j2ee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>QuoteServlet</servlet-name>
<jsp-file>/quote.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>QuoteServlet</servlet-name>
<url-pattern>/quote</url-pattern>
</servlet-mapping>
</web-app>

最后,build.xml:

    <project name="quote" basedir="../" default="deploy">

    <!-- Project settings -->
    <property name="project.distname" value="quote"/>

    <!-- Local system paths -->
    <property file="${basedir}/ant/build.properties"/>
    <property name="webroot.dir" value="${basedir}\WebContent"/>
    <property name="webinf.dir" value="${webroot.dir}\WEB-INF"/>
    <property name="build.dir" value="build"/>

    <!-- classpath for JSF 1.1.01 -->
    <path id="compile.classpath">
        <pathelement path ="${webinf.dir}/lib/commons-beanutils.jar"/>
        <pathelement path ="${webinf.dir}/lib/commons-collections.jar"/>
        <pathelement path ="${webinf.dir}/lib/commons-digester.jar"/>
        <pathelement path ="${webinf.dir}/lib/commons-logging.jar"/>
        <pathelement path ="${webinf.dir}/lib/jsf-api.jar"/>
        <pathelement path ="${webinf.dir}/lib/jsf-impl.jar"/>
        <pathelement path ="${webinf.dir}/lib/jstl.jar"/>
        <pathelement path ="${webinf.dir}/lib/standard.jar"/>
        <pathelement path ="${webinf.dir}/classes"/>
        <pathelement path ="${classpath.external}"/>
        <pathelement path ="${classpath}"/>
    </path>

    <!-- define your folder for deployment -->
    <property name="deploy.dir" value="deploy"/>


    <!-- Check timestamp on files -->
    <target name="prepare">
        <tstamp/>
    </target>

    <!-- Copy any resource or configuration files -->
    <target name="resources">
        <copy todir="${webinf.dir}/classes" includeEmptyDirs="no">
            <fileset dir="JavaSource">
            <patternset>
                <include name="**/*.conf"/>
                <include name="**/*.properties"/>
                <include name="**/*.xml"/>
            </patternset>
            </fileset>
        </copy>
    </target>

    <!-- Normal build of application -->
    <target name="compile" depends="prepare,resources">
        <javac srcdir="JavaSource" destdir="${webinf.dir}/classes">
            <classpath refid="compile.classpath"/>
        </javac>
    </target>

    <!-- Remove classes directory for clean build -->
    <target name="clean"
      description="Prepare for clean build">
      <delete dir="${webinf.dir}/classes"/>
      <mkdir  dir="${webinf.dir}/classes"/>
    </target>

    <!-- Build entire project -->
    <target name="build" depends="prepare,compile"/>
    <target name="rebuild" depends="clean,prepare,compile"/>

    <!-- Create binary distribution -->
    <target name="war" depends="build">
      <mkdir dir="${build.dir}"/>
      <war
        basedir="${webroot.dir}"
        warfile="${build.dir}/${project.distname}.war"
        webxml="${webinf.dir}\web.xml">
        <exclude name="WEB-INF/${build.dir}/**"/>
        <exclude name="WEB-INF/src/**"/>
        <exclude name="WEB-INF/web.xml"/>
       </war>

    </target>

    <target name="deploy" depends="war">
       <delete file="${deploy.dir}/${project.distname}.war"/>
       <delete dir="${deploy.dir}/${project.distname}"/>
       <copy file="${build.dir}/${project.distname}.war" todir="${deploy.dir}"/>
    </target>

</project>

很抱歉在這里是一個混亂的錯誤。 但是建議將不勝感激。

假設您將war文件部署在

C:\JBoss\jboss-6.0.0.Final\server\default\deploy\quote.war

並啟動了JBoss的默認配置文件

C:\JBoss\jboss-6.0.0.Final\bin\run.bat

並且在您的日志文件中看不到任何錯誤

C:\JBoss\jboss-6.0.0.Final\server\default\log\server.log

您應該能夠看到已部署的應用程序,並且應該能夠使用http:// localhost:8080 / quote.jsphttp:// localhost:8080 / quote / quote.jsp訪問它

希望這可以幫助。

祝好運!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM