[opencms-dev] RE: calling servlet from jsp
Harvey Bernstein
hb at bsemple.com
Thu Dec 4 17:04:01 CET 2003
Hello Guys
I would like to be able to call Servlets from JSP's. I've gone through the
list archive and this seems to be possible. Frank Wunderlich suggested that
the Servlet class file should be imported into openCms and several settings
in the web.xml file should be added.
I have created a very simple helloWorld servlet which I have imported into a
newly created module as a binary file. I have also made the suggested
changes to the web.xml file. Now I try to call the newly created servlet
from a jsp but the newly created servlet cannot be found. I was expecting
the servlet to be published to the classes folder in WEB-INF under the
openCMS directory but nothing is here.
Is there any detailed instructions that explain how to use Servlets with
openCMS? Is the approach I have taken wrong?
Thanks in advance
Best wishes
Harvey
Hi Philipp,
I think, it's just like in any other webapplication:
1. The servlet classes have to be visible in the classpath of the
opencms webapp.
That means they have to be placed somewhere down the
opencms/WEB-INF/classes directory (or WEB-INF/lib for jars).
As far as I know, but I'm not quite sure about that, they are
automatically published to this place, when you store your classes
inside a opencms module (e.g. system/module/mymodule/classes).
2. The next step is to register the servlet class in web.xml
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
...
</servlet>
<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>/struts/*</url-pattern>
</servlet-mapping>
3. Just place a link to your servlet url somewhere in your
opencms-templates / pages / whatever...
As you can see, you can even integrate a MVC-framework like Apache
Struts easily into Opencms. The views/jsps used by Struts can even be
edited inside Opencms.
Greetings,
Frank.
>
>
> Hi :)
>
> I want to use a Servlet with OpenCMS 5.0.
>
> Has anyone informations about using servlets in OpenCMS 5.0?
>
>
> Greetings
>
> Philipp
>
>
>
>
>
> Enrico Olla schrieb:
>
> >Hi List,
> >
> >I wrote some servlet for my application and now I saved
> these classes
> >in system/module/mymodule/classes. Now I want process some
> data from a
> >form in a jsp created in /MyProject I tried to perform the
> form action
> >with /servlet/myservlet but not work.
> >
> >What is the correct way to call a servlet in my module?
> >
> >Thanx,
> >Olen.
> >
> >
> >
> >_______________________________________________
> >This mail is send to you from the opencms-dev mailing list
> >To change your list options, or to unsubscribe from the list, please
> >visit http://mail.opencms.org/mailman/listinfo/opencms-dev
> >
> >
> >
> >
>
>
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list,
> please visit http://mail.opencms.org/mailman/listinfo/opencms-dev
>
This e-mail has been scanned for all viruses by MessageLabs.
More information about the opencms-dev
mailing list