You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Andrew J. Dick" <aj...@echoworx.com> on 2000/09/05 22:50:30 UTC

TomCat, taglibs, and servlet mapping

Hi all,

  I am trying to get a webapp running on tomcat 3.1 standalone.  I have ripped
out the templating portion of the
java petstore that I had running under weblogic 5.1.  I cannot seem to get the
servlet mapping to trigger to the
appropriate servlet.  First off, the FAQ describes using servlet classes
whereas the example I have maps to a
jsp, so I am not sure if this will make a difference or not.

However the following are the steps I took:

1.) Created a directory under tomcat/webapps called foo.
2.) In tomcat/webapp/foo, I created a WEB-INF directory.
3.) In tomcat/webapp/foo/WEB-INF I placed a web.xml file with the following:
    <web-app>
      <display-name>WebTier</display-name>
      <servlet>
        <servlet-name>webTierEntryPoint</servlet-name>
        <display-name>centralJsp</display-name>
        <jsp-file>Main.jsp</jsp-file>
      </servlet>
      <servlet-mapping>
        <servlet-name>webTierEntryPoint</servlet-name>
        <url-pattern>/control/*</url-pattern>
      </servlet-mapping>
        <welcome-file-list>
        <welcome-file>/index.html</welcome-file>
      </welcome-file-list>
</web-app>

4.) In tomcat/webapp/foo/WEB-INF I placed a directory tlds with the foo.tld
file which holds the template definitions.
5.) In tomcat/webapp/foo I placed all the required jsp files and the
index.html welcome page.
6.) In tomcat/conf/server.xml I added the following line:
      <Context path="/foo" docBase="webapps/foo" debug="1" reloadable="true"
></Context>

This works for weblogic perfectly, with the appropriate change for step 6, .
This afternoon I reinstalled the webapp on weblogic,
made sure it was working, tarred it up and placed it under the appropriate
directory for tomcat and I get the following error:

Error: 500

Location: /foo/control/page1

Internal Servlet Error:

java.lang.NullPointerException:
        at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:398)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
        at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160)

        at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
        at java.lang.Thread.run(Thread.java:475)

Any ideas, suggestions or similar experiences anyone?

Thanks for any advice.

Andrew



Tomcat and JServ Installation

Posted by Kelly O'Hoy <ke...@hkiwa.org>.
Dear all,

I'm new to JSP and Servlet....and I'd like install the Servlet Engine and
the JSP Plug-in for Apache....

What software do I need to go that?
What's the different between Tomcat and JServ?
How do I install them to be a Apache Module?

Sorry for so many questions....
If it's too long to write here....please divert me to any good tutorial on
the net~

Thanks

Kelly



Re: TomCat, taglibs, and servlet mapping

Posted by "Andrew J. Dick" <aj...@echoworx.com>.
Hi Craig,

>
> Yes, if you want to do things the way that the Blueprints app does it (PetStore), then <jsp-file> is correct.
>

So then my problem is still that doing things the way that Blueprint does it results in the exception under
Tomcat
but not under Weblogic.

====


Error: 500

Location: /foo/control/page1

Internal Servlet Error:

java.lang.NullPointerException:
        at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:398)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
        at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160)

        at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
        at java.lang.Thread.run(Thread.java:475)




Re: TomCat, taglibs, and servlet mapping

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
"Andrew J. Dick" wrote:

> Thanks for your quick response Craig.
>
> > > 2.) In tomcat/webapp/foo, I created a WEB-INF directory.
> >
> > I am assuming that you really mean "tomcat/webapps" from here on, not "tomcat/webapp", right?
> >
>
> Yep typo.  :)
>

:-)

>
> >
> > >
> > > 3.) In tomcat/webapp/foo/WEB-INF I placed a web.xml file with the following:
> > >     <web-app>
> > >       <display-name>WebTier</display-name>
> > >       <servlet>
> > >         <servlet-name>webTierEntryPoint</servlet-name>
> > >         <display-name>centralJsp</display-name>
> > >         <jsp-file>Main.jsp</jsp-file>
> > >
> >
>
> If I want to use the Main.jsp as the recepient of the mapped requests, <jsp-file> would be correct would it
> not?
>

Yes, if you want to do things the way that the Blueprints app does it (PetStore), then <jsp-file> is correct.

>
> >
> > If you want to use a servlet instead of a JSP page, you should replace <jsp-file> with a <servlet-class>
> > element, to tell Tomcat what Servlet class to load.  Something like:
> >
> >             <servlet-class>com.mycompany.mypackage.MyServlet</servlet-class>
> >
>

Yep.

>
> Andrew

Craig

====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat



Re: TomCat, taglibs, and servlet mapping

Posted by "Andrew J. Dick" <aj...@echoworx.com>.
Thanks for your quick response Craig.


> > 2.) In tomcat/webapp/foo, I created a WEB-INF directory.
>
> I am assuming that you really mean "tomcat/webapps" from here on, not "tomcat/webapp", right?
>

Yep typo.  :)


>
> >
> > 3.) In tomcat/webapp/foo/WEB-INF I placed a web.xml file with the following:
> >     <web-app>
> >       <display-name>WebTier</display-name>
> >       <servlet>
> >         <servlet-name>webTierEntryPoint</servlet-name>
> >         <display-name>centralJsp</display-name>
> >         <jsp-file>Main.jsp</jsp-file>
> >
>

If I want to use the Main.jsp as the recepient of the mapped requests, <jsp-file> would be correct would it
not?

>
> If you want to use a servlet instead of a JSP page, you should replace <jsp-file> with a <servlet-class>
> element, to tell Tomcat what Servlet class to load.  Something like:
>
>             <servlet-class>com.mycompany.mypackage.MyServlet</servlet-class>
>

Andrew



Re: TomCat, taglibs, and servlet mapping

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
See embedded comments below.

"Andrew J. Dick" wrote:

> Hi all,
>
>   I am trying to get a webapp running on tomcat 3.1 standalone.  I have ripped
> out the templating portion of the
> java petstore that I had running under weblogic 5.1.  I cannot seem to get the
> servlet mapping to trigger to the
> appropriate servlet.  First off, the FAQ describes using servlet classes
> whereas the example I have maps to a
> jsp, so I am not sure if this will make a difference or not.
>
> However the following are the steps I took:
>
> 1.) Created a directory under tomcat/webapps called foo.
> 2.) In tomcat/webapp/foo, I created a WEB-INF directory.

I am assuming that you really mean "tomcat/webapps" from here on, not "tomcat/webapp", right?

>
> 3.) In tomcat/webapp/foo/WEB-INF I placed a web.xml file with the following:
>     <web-app>
>       <display-name>WebTier</display-name>
>       <servlet>
>         <servlet-name>webTierEntryPoint</servlet-name>
>         <display-name>centralJsp</display-name>
>         <jsp-file>Main.jsp</jsp-file>
>

If you want to use a servlet instead of a JSP page, you should replace <jsp-file> with a <servlet-class>
element, to tell Tomcat what Servlet class to load.  Something like:

            <servlet-class>com.mycompany.mypackage.MyServlet</servlet-class>

>       </servlet>
>       <servlet-mapping>
>         <servlet-name>webTierEntryPoint</servlet-name>
>         <url-pattern>/control/*</url-pattern>
>       </servlet-mapping>
>         <welcome-file-list>
>         <welcome-file>/index.html</welcome-file>
>       </welcome-file-list>
> </web-app>
>
> 4.) In tomcat/webapp/foo/WEB-INF I placed a directory tlds with the foo.tld
> file which holds the template definitions.

This is fine, but not required.  You can put TLDs directly in /WEB-INF if you want to, but you need to
make sure that your references point to the correct places.

>
> 5.) In tomcat/webapp/foo I placed all the required jsp files and the
> index.html welcome page.
> 6.) In tomcat/conf/server.xml I added the following line:
>       <Context path="/foo" docBase="webapps/foo" debug="1" reloadable="true"
> ></Context>
>

This is fine, but not necessary unless you want to override the default context configuration parameters.
In this case, you set debug="1" which is non default, and that is fine.

>
> This works for weblogic perfectly, with the appropriate change for step 6, .
> This afternoon I reinstalled the webapp on weblogic,
> made sure it was working, tarred it up and placed it under the appropriate
> directory for tomcat and I get the following error:
>
> Error: 500
>
> Location: /foo/control/page1
>
> Internal Servlet Error:
>
> java.lang.NullPointerException:
>         at
> org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:398)
>         at

This is most likely because of the missing <servlet-class> entry defined above.

>
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
>         at
> org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160)
>
>         at
> org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
>         at java.lang.Thread.run(Thread.java:475)
>
> Any ideas, suggestions or similar experiences anyone?
>
> Thanks for any advice.
>
> Andrew

Craig McClanahan

====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat