You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by jonathan porterfield <a0...@hotmail.com> on 2001/09/03 18:24:01 UTC

servlet won't initialize

Some facts
- Using TDK 2.1
- Successfully built and adaquately played with the sample site - (Something 
works)
- Have added a couple stand-alone Velocity pages to the sample site.
- Now want to add servlet/template pages

1) Using the "Velocity Site How-To" I have created two files, ripped almost 
exactly from the doc.
----------------------------------------------------------------
a. HelloWorld.vm
----------------------------------------------------------------
<p>
    <font color="red">
        $hello of the emergency broadcast station.
    </font>
</p>

----------------------------------------------------------------
b. HelloWorld.class (no errors compiling )
----------------------------------------------------------------
// Velocity Stuff
import org.apache.velocity.context.Context;
import java.util.Vector;

// Turbine Stuff
import org.apache.turbine.util.RunData;
import org.apache.turbine.modules.screens.VelocityScreen;

public class HelloWorld extends VelocityScreen
{
public final String hello = "This is a test";

    public void doBuildTemplate( RunData data, Context context )
        throws Exception
    {
        // the context object has already been setup for you!
        context.put ("hello", hello);
    }

  public String getHello(){
    return hello;
  }

}
----------------------------------------------------------------
----------------------------------------------------------------

3) I dropped the .vm file in:
   [fullpath]\myapp\templates\app\screens

4) And the .class file in
   [fullpath]\myapp\WEB-INF\classes\com\myco\myapp\modules\screens

5) I added the .class file to the classpath

6) I registered the servet in web.xml as such
  <servlet>
    <servlet-name>HelloWorld</servlet-name>
    <servlet-class>HelloWorld.class</servlet-class>
    <init-param>
      <param-name>properties</param-name>
      <param-value>/velocity.properties</param-value>
    </init-param>
  </servlet>

7) I added the link to the navigation on the sample app
<a href="$link.setPage("HelloWorld.vm")">HelloWorld</a>
and it works, well sort of.

8) Started Tomcat

----------------------------------------------------------------
Here's the problem
----------------------------------------------------------------
The Flux docs fly just fine, when I click the link for my own lame attempt, 
the output from the request is a vapid
"$hello of the emergency broadcast station."

This, as I understand it, is due to the servlet failing to initialize and 
dump something into the context called $hello. (push model)

What am I missing?
I turn to the list ...

Thanks in advance to any who can respond.


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: servlet won't initialize

Posted by Heiko Braun <he...@fork.de>.
You cant't add the HelloWorld.class
as a servlet to your container, because it is
no servlet.

Turbine itself is the servlet and calling
$link.setPage("Foo.vm") triggers the turbine
internals which look for the coresponding
screen class "HelloWorld" and merge it with the template.

Just remove the parts from web.xml and everything
should be working fine.

For more information about take a look at:
http://jakarta.apache.org/turbine/turbine-2/fsd.html

rgds,

 --
 heiko braun, fork unstable media
 http://www.unstablemedia.com


On Mon, 3 Sep 2001, jonathan porterfield wrote:

> Some facts
> - Using TDK 2.1
> - Successfully built and adaquately played with the sample site - (Something
> works)
> - Have added a couple stand-alone Velocity pages to the sample site.
> - Now want to add servlet/template pages
>
> 1) Using the "Velocity Site How-To" I have created two files, ripped almost
> exactly from the doc.
> ----------------------------------------------------------------
> a. HelloWorld.vm
> ----------------------------------------------------------------
> <p>
>     <font color="red">
>         $hello of the emergency broadcast station.
>     </font>
> </p>
>
> ----------------------------------------------------------------
> b. HelloWorld.class (no errors compiling )
> ----------------------------------------------------------------
> // Velocity Stuff
> import org.apache.velocity.context.Context;
> import java.util.Vector;
>
> // Turbine Stuff
> import org.apache.turbine.util.RunData;
> import org.apache.turbine.modules.screens.VelocityScreen;
>
> public class HelloWorld extends VelocityScreen
> {
> public final String hello = "This is a test";
>
>     public void doBuildTemplate( RunData data, Context context )
>         throws Exception
>     {
>         // the context object has already been setup for you!
>         context.put ("hello", hello);
>     }
>
>   public String getHello(){
>     return hello;
>   }
>
> }
> ----------------------------------------------------------------
> ----------------------------------------------------------------
>
> 3) I dropped the .vm file in:
>    [fullpath]\myapp\templates\app\screens
>
> 4) And the .class file in
>    [fullpath]\myapp\WEB-INF\classes\com\myco\myapp\modules\screens
>
> 5) I added the .class file to the classpath
>
> 6) I registered the servet in web.xml as such
>   <servlet>
>     <servlet-name>HelloWorld</servlet-name>
>     <servlet-class>HelloWorld.class</servlet-class>
>     <init-param>
>       <param-name>properties</param-name>
>       <param-value>/velocity.properties</param-value>
>     </init-param>
>   </servlet>
>
> 7) I added the link to the navigation on the sample app
> <a href="$link.setPage("HelloWorld.vm")">HelloWorld</a>
> and it works, well sort of.
>
> 8) Started Tomcat
>
> ----------------------------------------------------------------
> Here's the problem
> ----------------------------------------------------------------
> The Flux docs fly just fine, when I click the link for my own lame attempt,
> the output from the request is a vapid
> "$hello of the emergency broadcast station."
>
> This, as I understand it, is due to the servlet failing to initialize and
> dump something into the context called $hello. (push model)
>
> What am I missing?
> I turn to the list ...
>
> Thanks in advance to any who can respond.
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org