Announcement Announcement Module
Collapse
No announcement yet.
Can not display jsp page Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can not display jsp page

    Hi ,

    I am trying to develop a sample login application. But, I can not display the login page. My web.xml configuration is as follows:

    Code:
     <servlet>
            <servlet-name>SpringMVC</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>   
    
        
        <servlet-mapping>
            <servlet-name>SpringMVC</servlet-name>
            <url-pattern>*.jsp</url-pattern>
        </servlet-mapping>
    My application context configuration is as follows:

    Code:
    <beans>
     <bean id="loginController" class="com.jbe.spring.controller.LoginController">
        <property name="commandClass"><value>com.jbe.spring.command.LoginCommand</value></property>
        <property name="commandName"><value>loginCommand</value></property>
        <property name="formView"><value>login</value></property>
     </bean>
     
     <bean id="indexController" class="com.jbe.spring.controller.IndexController"/>
     
     <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="cache" value="true"/>
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
     </bean>
     
     <bean id="simpleUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
      <property name="mappings">
        <props>
            <prop key="/index.jsp">indexController</prop> 
            <prop key="/login.jsp">loginController</prop>      
        </props>
      </property>
    </bean>
    </beans>
    When I try to call the url :
    Code:
    http://localhost:7001/SpringMVCTutorialWeb/index.jsp
    , where the index is the welcome file.

    I get the following log message:
    Code:
    2006-06-07 15:02:44,723 [ExecuteThread: '14' for queue: 'weblogic.kernel.Default'] DEBUG org.springframework.web.servlet.DispatcherServlet:926 - Rende
    ring view [org.springframework.web.servlet.view.JstlView: name 'login'; URL [/WEB-INF/jsp/login.jsp]] in DispatcherServlet with name 'SpringMVC'
    2006-06-07 15:02:44,723 [ExecuteThread: '14' for queue: 'weblogic.kernel.Default'] DEBUG org.springframework.web.servlet.view.JstlView:234 - Rendering
     view with name 'login' with model null and static attributes {}

    I have used the following index controller :
    Code:
    public class IndexController implements Controller
    { 
        protected final Log log = LogFactory.getLog(getClass());
        
        public ModelAndView handleRequest(HttpServletRequest arg0, HttpServletResponse arg1) throws Exception
        {
             log.info(" <<<<<<<<<<<<<<<<<<<<<<<<<<< Begin handleRequest >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ");
         
             log.info("<<<<<<<<<<<<<<<<<<<<<<<<< End handle request class >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ");
            return new ModelAndView("login");
        }
    }
    Can anybody please help me.

    Thanks,

    Krishnan

  • #2
    It looks like the view-rendering is dispatching to your /WEB-INF/jsp/login.jsp. Although you are not seeing the log messages from within the IndexController, have you checked the configuration of the relevant log levels? What actually appears in the browser?

    Comment


    • #3
      It does not display anything

      Hi Mark,

      Not a thing.

      Thanks,

      Krishnan

      Comment


      • #4
        It does not display the page

        Hi Mark,

        It displays the log messages but does not display the page.

        Thanks,

        Krishnan

        Comment


        • #5
          What do you have in "/WEB-INF/jsp/login.jsp"?

          Comment


          • #6
            Index and Login jsp

            Index jsp:
            ---------

            Code:
            <!--Generated by WebLogic Workshop-->
            <%@ page language="java" contentType="text/html;charset=UTF-8"%>
            <%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
            
            <html>
              <head><title>Example :: Spring Application</title></head>
            <body>
            <form>
            <h1>Hello - Spring Application</h1>
            <p>Greetings.</p>
              <c:redirect url="/login.htm"/>
            </form>
            </body>
            </html>
            Login jsp
            --------

            Code:
             <%@ page language="java" contentType="text/html;charset=UTF-8"%>
            
            <html>
                <head><title>Login Please !!! </title></head>
                <body>
                    <form>
                        <table>
                           <tr>
                            <td>If you have a login id, please login in</td>
                            <td>Enter you User Name below</td>
                           </tr>
                            <tr>
                                <td>Username</td>
                                <td><input type="text" name="userId"></td>                    
                            </tr>
                            <tr>
                                <td>Password</td>
                               <td><input type="password" name="password"></td> 
                            </tr>
                            <tr>
                                <td>&nbsp;</td>
                                <td><input type="submit" name="login" value="Login">
                            </tr>
                            
                        </table>
                    </form>
                </body>
            </html>
            Thanks,

            Krishnan

            Comment


            • #7
              Your servlet mapping is causing anything with a ".jsp" prefix to be handled by the DispatcherServlet. Your welcome page should not conflict with that prefix. Also, the redirect to "login.htm" would not be handled by the DispatcherServlet.

              Comment


              • #8
                Can Not Find the Handler Class

                Hi Mark,

                Looking at your mail, I changed the following references in various files:

                1) web.xml
                --------
                Code:
                <servlet>
                        <servlet-name>SpringMVC</servlet-name>
                        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                        <load-on-startup>1</load-on-startup>
                    </servlet>   
                
                    
                    <servlet-mapping>
                        <servlet-name>SpringMVC</servlet-name>
                        <url-pattern>*.htm</url-pattern>
                    </servlet-mapping>
                2) The SpringMVC-servlet.xml
                --------------------------

                Code:
                 <bean id="loginController" class="com.jbe.spring.controller.LoginController">
                    <property name="commandClass"><value>com.jbe.spring.command.LoginCommand</value></property>
                    <property name="commandName"><value>loginCommand</value></property>
                    <property name="formView"><value>login</value></property>
                 </bean>
                 
                 <bean id="indexController" class="com.jbe.spring.controller.IndexController"/>
                 
                 <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                    <property name="cache" value="true"/>
                    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
                    <property name="prefix" value="/WEB-INF/jsp/"/>
                    <property name="suffix" value=".jsp"/>
                 </bean>
                 
                 <bean id="simpleUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
                  <property name="mappings">
                    <props>
                        <prop key="/index.htm">indexController</prop> 
                        <prop key="/login.htm">loginController</prop>      
                    </props>
                  </property>
                </bean>
                index.jsp
                --------

                Code:
                 <!--Generated by WebLogic Workshop-->
                <%@ page language="java" contentType="text/html;charset=UTF-8"%>
                <%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
                
                <html>
                  <head><title>Example :: Spring Application</title></head>
                <body>
                <form>
                <h1>Hello - Spring Application</h1>
                <p>Greetings.</p>
                  <c:redirect url="/login.htm"/>
                </form>
                </body>
                </html>
                4) login.jsp
                --------

                Code:
                 <%@ page language="java" contentType="text/html;charset=UTF-8"%>
                
                <html>
                    <head><title>Login Please !!! </title></head>
                    <body>
                        <form>
                            <table>
                               <tr>
                                <td>If you have a login id, please login in</td>
                                <td>Enter you User Name below</td>
                               </tr>
                                <tr>
                                    <td>Username</td>
                                    <td><input type="text" name="userId"></td>                    
                                </tr>
                                <tr>
                                    <td>Password</td>
                                   <td><input type="password" name="password"></td> 
                                </tr>
                                <tr>
                                    <td>&nbsp;</td>
                                    <td><input type="submit" name="login" value="Login">
                                </tr>
                                
                            </table>
                        </form>
                    </body>
                </html>
                Now I get the following error:

                Code:
                 2006-06-07 16:01:09,897 [ExecuteThread: '1' for queue: 'weblogic.kernel.System'] ERROR org.springframework.web.servlet.DispatcherServlet:227 - Context
                 initialization failed
                org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'loginController' defined in ServletContext resource
                [/WEB-INF/SpringMVC-servlet.xml]: Bean class [com.jbe.spring.controller.LoginController] not found; nested exception is java.lang.ClassNotFound
                Exception: com.jbe.spring.controller.LoginController
                java.lang.ClassNotFoundException: com.jbe.spring.controller.LoginController
                        at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:199)
                        at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
                        at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
                        at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:224)
                        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
                        at java.lang.Class.forName0(Native Method)
                        at java.lang.Class.forName(Class.java:219)
                        at org.springframework.util.ClassUtils.forName(ClassUtils.java:88)
                        at org.springframework.beans.factory.support.BeanDefinitionReaderUtils.createBeanDefinition(BeanDefinitionReaderUtils.java:65)
                        at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinitionElement(DefaultXmlBeanDefinitionParser.java:369)
                        at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinitionElement(DefaultXmlBeanDefinitionParser.java:335)
                        at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinitions(DefaultXmlBeanDefinitionParser.java:266)
                        at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.registerBeanDefinitions(DefaultXmlBeanDefinitionParser.java:186)
                        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:246)
                        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:163)
                        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:125)
                        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:141)
                        at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:126)
                        at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
                        at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:89)
                
                        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:268)
                        at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
                
                        at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:305)
                        at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:250)
                        at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:219)
                        at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:112)
                        at javax.servlet.GenericServlet.init(GenericServlet.java:258)
                        at weblogic.servlet.internal.ServletStubImpl$ServletInitAction.run(ServletStubImpl.java:1094)
                        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
                        at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:970)
                        at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:949)
                        at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:888)
                        at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:3430)
                        at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext.java:3375)
                        at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:3356)
                        at weblogic.servlet.internal.WebAppServletContext.setStarted(WebAppServletContext.java:6208)
                        at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:864)
                        at weblogic.j2ee.J2EEApplicationContainer.start(J2EEApplicationContainer.java:2134)
                        at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2175)
                        at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.activateContainer(SlaveDeployer.java:2520)
                        at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.doCommit(SlaveDeployer.java:2438)
                        at weblogic.management.deploy.slave.SlaveDeployer$Task.commit(SlaveDeployer.java:2155)
                        at weblogic.management.deploy.slave.SlaveDeployer$Task.checkAutoCommit(SlaveDeployer.java:2254)
                        at weblogic.management.deploy.slave.SlaveDeployer$Task.prepare(SlaveDeployer.java:2149)
                        at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare(SlaveDeployer.java:2401)
                        at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:883)
                        at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(SlaveDeployer.java:591)
                        at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:500)
                        at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:25)
                        at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
                        at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
                <Jun 7, 2006 4:01:09 PM PDT> <Error> <HTTP> <BEA-101216> <Servlet: "SpringMVC" failed to preload on startup in Web application: "SpringMVCTutorialWeb"

                Comment


                • #9
                  That is a classpath issue... "com.jbe.spring.controller.LoginController" is not found. It shouldn't be related to those config changes you made - and those do make sense by the way.

                  Comment

                  Working...
                  X