users@glassfish.java.net

Re: Glassfish requested resource () is not available servlet issue

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Tue, 12 Jan 2010 13:24:45 -0800

When you launch an application from the admin console, you will access
it at its document root. In your example, the launch link would look
as follows:

  localhost:8080/HelloWorldServlet/

When you access an application at its document root, the container
will check the application's document root folder for any welcome pages.

You can define your own welcome page(s) in your application, but
unless you do so, your application will inherit a predefined list of welcome
pages from your domain's default-web.xml descriptor, which looks like this:

  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

Try placing a file with one of the above names in your application's
document
root, and you'll notice that when you click on the launch link for your
app, the
contents of its welcome page will be served.

If your app does not contain any welcome pages, the container would
normally generate a directory listing of its docroot folder. By
default, this functionality is disabled for security reasons, but can
be enabled by setting the init parameter with name "listings" of the
"default" Servlet, which is declared in default-web.xml, to "true".
This will enable directory listings globally (for all apps).
Alternatively, you
may enable directory listings for your app only, by setting "listings" to
"true" in your app's sun-web.xml descriptor.

Hope this helps.

Jan

On 01/12/10 12:29 PM, glassfish_at_javadesktop.org wrote:
> I'm a beginner trying to get a very simple servlet working.<P>
>
> The servlet is HelloWorldServlet (code below).
> I have placed the class in the HelloWorldServlet/WEB_INF/classes folder.
> I configure the web.xml as indicated below.<P>
>
> I can deploy the application successfully with the command:
> asadmin deploy HelloWorldServlet<P>
>
> I can then see the application under Applications in the Glassfish web admin interface. I then click on Launch to start the app and I get the following:<P>
>
> HTTP Status 404 -<BR>
> type Status report<BR>
> message<BR>
> descriptionThe requested resource () is not available.<P>
>
> Any ideas on how to fix this are appreciated. Thanks.<P>
> <P>
>
> HelloWorldServlet compiled in HelloWorldServlet/WEB_INF/classes:<P>
> --------------------------------------------------------------------------------------------------<P>
> import java.sql.*;<BR>
> import java.io.*;<BR>
> import java.util.*;<BR>
> import javax.servlet.*;<BR>
> import javax.servlet.http.*;<BR>
> <BR>
> public class HelloWorldServlet extends HttpServlet<BR>
> {<BR>
> public void doGet(HttpServletRequest inRequest, HttpServletResponse outResponse)<BR>
> throws ServletException, IOException<BR>
> {<BR>
> PrintWriter out = null;<BR>
> <BR>
> outResponse.setContentType("test/html");<BR>
> out = outResponse.getWriter();<BR>
> <BR>
> out.println("Hello World");<BR>
> }<BR>
> <BR>
> public void doPost(HttpServletRequest inRequest, HttpServletResponse outResponse)<BR>
> throws ServletException, IOException<BR>
> {<BR>
> doGet(inRequest, outResponse);<BR>
> }<BR>
> }<BR>
> --------------------------------------------------------------------------------<BR>
> <BR>
> web.xml in HelloWorldServlet/WEB_INF:<BR>
> ---------------------------------------------------------------------------------<BR>
> <?xml version="1.0" encoding="UTF-8"?><BR>
> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd"><BR>
> <BR>
> <web-app><BR>
> <display-name>HelloWorldServlet</display-name><BR>
> <description>Hello world test servlet</description><BR>
> <BR>
> <servlet><BR>
> <servlet-name>HelloWorldServlet</servlet-name><BR>
> <servlet-class>HelloWorldServlet</servlet-class><BR>
> </servlet><BR>
> <BR>
> <servlet-mapping><BR>
> <servlet-name>HelloWorldServlet</servlet-name><BR>
> <url-pattern>/hey</url-pattern><BR>
> </servlet-mapping><BR>
> <BR>
> </web-app><BR>
> [Message sent by forum member 'pimathieu' (mathieu_at_nrcan.gc.ca)]
>
> http://forums.java.net/jive/thread.jspa?messageID=380428
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>