views:

689

answers:

1

I'm trying to get a servlet built and running in Netbeans to run on a jetty server. Deploying locally always works, however deploying on Jetty results in a directory listing rather than the servlet actually running.

The problem seems to be with the context configuration, but I have no idea what I'm doing wrong.

Here is the XML for web.xml in the war file:

<?xml version="1.0" encoding="UTF-8"?>
<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"&gt;
<servlet>
    <description>Raw Query</description>
    <servlet-name>query</servlet-name>
    <servlet-class>core.SQL</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>query</servlet-name>
    <url-pattern>/query</url-pattern>
</servlet-mapping>
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

On the Jetty side, I'm deploying with a contex mapping setup this way:

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" 
"http://jetty.mortbay.org/configure.dtd"&gt;

<Configure class="org.mortbay.jetty.webapp.WebAppContext">
    <Set name="contextPath">/query</Set>
    <Set name="war">
        <SystemProperty name="jetty.home" default="."/>/webapps/Link/I5Link.war
    </Set>
</Configure>

Any help greatly appricated.

+1  A: 

Hi,

I have not worked with jetty but I would test the following url:

http://localhost:8080/query/query?whateverYouNeed

If it works, I would change your <url-pattern> for one of the following:

<url-pattern>/</url-pattern>

<url-pattern>*</url-pattern>

ATorras
Thank you! I'm very new to the servlet side of Java and this was driving me nuts. I think I'm starting to understand. Thanks again.
David Hamilton
I'm glad you understood by yourself ;)
ATorras