6 Replies Latest reply on Nov 20, 2012 4:51 PM by sfcoy

    JBoss 7.1.1 newbie

    hoffz31

      Sorry I am new to JBoss and can't seem to get a simple JSP to work.  I am deploying to JBoss 7.1.1 via eclipse.  The war deploys fine, it is registered in the console managed applications.  I have attached my web.xml and jboss-web.xml.  I don't receive any errors except a 404 when I go to http://localhost:8080/mike/index.jsp .  I have even tried a simpel html page with no luck.  My index.jsp is under WEB-INF.

       

      web.xml

       

      <?xml version="1.0" encoding="UTF-8"?>

      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"

          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"

          id="WebApp_ID" version="3.0">

         

          <display-name>mike</display-name>

         

          <welcome-file-list>

              <welcome-file>index.html</welcome-file>

              <welcome-file>index.htm</welcome-file>

              <welcome-file>index.jsp</welcome-file>

              <welcome-file>default.html</welcome-file>

              <welcome-file>default.htm</welcome-file>

              <welcome-file>default.jsp</welcome-file>

          </welcome-file-list>

      </web-app>

       

      jboss-web.xml

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE jboss-web PUBLIC

        "-//JBoss//DTD Web Application 5.0//EN"

        "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">

       

      <jboss-web>

          <context-root>/mike</context-root>

      </jboss-web>

       

       

      index.html

      <html>

      <head>

          

      </head>

      <body>

      Test

       

      </body>

      </html>

        • 1. Re: JBoss 7.1.1 newbie
          jaikiran

          hoffz31 wrote:

           

          My index.jsp is under WEB-INF.

          Move it outside of WEB-INF, directly into the .war.

          • 2. Re: JBoss 7.1.1 newbie
            hoffz31

            Thanks so much Jaikiran!

             

            I was use to packaging the content under WEB-INF.

            • 3. Re: JBoss 7.1.1 newbie
              jaikiran

              By the way, since you say you are a beginner, I would recommend you buy a Java EE book which explains the concepts in detail. Not all resources should be packaged outside of WEB-INF. There are some resource which should reside in the WEB-INF folder.

              • 4. Re: JBoss 7.1.1 newbie
                sfcoy

                It's a common strategy to package content such as JSP's in the WEB-INF directory. This is done because this directory is explicitly protected from direct access from a web browser.

                 

                The JSPs are rendered by invoking a java servlet or similar mechanism which then forwards to the WEB-INF/some-page.jsp for rendering the response:

                 

                {code:java}request.getRequestDispatcher("WEB-INF/some-page.jsp").forward(request, response);{code}

                • 5. Re: JBoss 7.1.1 newbie
                  hoffz31

                  Thanks Stephen,

                   

                  I am looking into setting up a simple JSF page using prime faces.  How would you recommend structuring the project?  Where would the .xhtml pages be placed?  Inside the WEB-INF?

                   

                   

                  Thanks again!

                  • 6. Re: JBoss 7.1.1 newbie
                    sfcoy

                    xhtml pages are typically JSF facelets, which have very little in common with JSPs aside from the notion of tag libraries and EL.

                     

                    I recommend that you have a look at the JBoss Developer Quickstarts that include JSF and start from there.

                     

                    I also found Core JavaServer Faces to be good too.