首页 > 代码库 > 布置第一个JBOSS服务器

布置第一个JBOSS服务器

还是要通过实践慢慢积累感觉。。

SERVLET的制作,JAVAC的编译。。。

package com.manning.jbia.intro;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@SuppressWarnings("serial")
public class HelloWorldServlet extends HttpServlet
{
    @Override
    public void service( HttpServletRequest request,
            HttpServletResponse response )
    throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        out.println( "<html><body>Hello World!</body></html>");
        out.close();
    }
}
<web-app version="2.5"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <servlet>
        <servlet-name>Hello Servlet</servlet-name>
    <servlet-class>
        com.manning.jbia.intro.HelloWorldServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Hello Servlet</servlet-name>
        <url-pattern>/sayhello</url-pattern>
    </servlet-mapping>
</web-app>

 

编译命令:

c:\>javac -classpath C:\jboss-5.1.0.GA\common\lib\servlet-api.jar -d C:\Users\hengheng\workspace\helloWorldBuild\helloapp.war\WEB-INF\classes C:\Users\hengheng\workspace\helloWorldBuild\src\com\manning\jbia\intro\*

然后,将包括XML和CLASS的WAR目录COPY到DEPLOY的相应目录下。

输出: