You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by alee amin <ma...@gmail.com> on 2009/02/04 09:16:58 UTC

[S2] Creating and calling a servlet in sturts2 app

hi,
I am having a struts application but due to some reason i want to create a
servlet in this application (which would return a json string) that is going
to be used in JSP (that would map in struts action page url) .. ..

I am unable to create the servlet and call it from that web. I have created
one, added the given servlet entry in web.xml and then tried to call it but
my request has not been dispatched to that servlet.

What should i do ?
..alee
http://techboard.wordpress.com

Re: [S2] Creating and calling a servlet in sturts2 app

Posted by alee amin <ma...@gmail.com>.
there is no error in logs. and yes .. invoking the servlet calls the struts
action. I don't think that servlet configuration has anything to do, since i
created it using eclipse wizard.

..alee
http://techboard.wordpress.com



On Wed, Feb 4, 2009 at 5:01 PM, Nils-Helge Garli Hegvik <ni...@gmail.com>wrote:

> I'm not sure I follow you. Are you saying that when you try to invoke
> the servlet, the struts action is invoked instead? Or is nothing
> invoked? And again, have you checked your logs for errors or any
> traces of what's happening? Maybe your servlet is not correctly
> configured so it's not started?
>
> Nils-H
>
> On Wed, Feb 4, 2009 at 11:20 AM, alee amin
> <ma...@gmail.com> wrote:
> > This is the entry that i made in web.xml for the servlet
> >
> >> <servlet>
> >>
> > <description>
> >>
> > </description>
> >>
> > <display-name>rawData</display-name>
> >
> > <servlet-name>rawData</servlet-name>
> >>
> > <servlet-class>com.e2e.servlet.rawData</servlet-class>
> >
> > </servlet>
> >>
> > <servlet-mapping>
> >>
> > <servlet-name>rawData</servlet-name>
> >>
> > <url-pattern>/data/rawData</url-pattern>
> >>
> > </servlet-mapping>
> >
> >
> > even if i try to call the servlet directly (direct writing the url in the
> > address bar) there is no call going to servlet, rather the struts action
> is
> > being called. here is the mapping for that stuts action
> >
> > <package name="reports" namespace="/report" extends="json-default">
> >>
> >  <action name="rawList" class="com.e2e.pin.web.actions.RawListAction">
> >>
> > <result type="json">
> >>
> > <param name="contentType">text/plain</param>
> >>
> > <param name="noCache">true</param>
> >>
> > </result>
> >>
> >      <interceptor-ref name="basicStack"/>
> >>
> >    </action>
> >>
> > </package>
> >
> >
> > no matter if i call servlet directly or indirectly, my call never reaches
> to
> > the servlet. how can i do this?
> >
> > ..alee
> > http://techboard.wordpress.com
> >
> >
> >
> > On Wed, Feb 4, 2009 at 1:36 PM, Nils-Helge Garli Hegvik <
> nilsga@gmail.com>wrote:
> >
> >> >
> >> > What should i do ?
> >>
> >> You could start by providing some more information. How do call the
> >> servlet, and how is it configured? Do you get any errors in your log
> >> files? Can you invoke the servlet by typing it's url in the browser?
> >>
> >> Nils-H
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: [S2] Creating and calling a servlet in sturts2 app

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
Ah, yes. I was thinking that the longest url match would win, but a
filter of course has higher priority than the servlet . So either do
as Andy suggested, or change the url mapping of the filter dispatcher
to something more specific, depending on your needs.

Nils-H

On Wed, Feb 4, 2009 at 4:03 PM, Andy <an...@hotmail.com> wrote:
>
> I ran into the same thing as the OP.  I think the FilterDispatcher is catching all requests to the servlet since it uses a url-mapping of /*.
>
>
>
> The Struts in Action book, from what I remember, suggests having an Action receive the request and then dispatch to a servlet.
>
>
>
> If anyone has direct experience with this please let us know.
>
>
>
>
>
>> Date: Wed, 4 Feb 2009 13:01:10 +0100
>> Subject: Re: [S2] Creating and calling a servlet in sturts2 app
>> From: nilsga@gmail.com
>> To: user@struts.apache.org
>>
>> I'm not sure I follow you. Are you saying that when you try to invoke
>> the servlet, the struts action is invoked instead? Or is nothing
>> invoked? And again, have you checked your logs for errors or any
>> traces of what's happening? Maybe your servlet is not correctly
>> configured so it's not started?
>>
>> Nils-H
>>
>> On Wed, Feb 4, 2009 at 11:20 AM, alee amin
>> <ma...@gmail.com> wrote:
>> > This is the entry that i made in web.xml for the servlet
>> >
>> >> <servlet>
>> >>
>> > <description>
>> >>
>> > </description>
>> >>
>> > <display-name>rawData</display-name>
>> >
>> > <servlet-name>rawData</servlet-name>
>> >>
>> > <servlet-class>com.e2e.servlet.rawData</servlet-class>
>> >
>> > </servlet>
>> >>
>> > <servlet-mapping>
>> >>
>> > <servlet-name>rawData</servlet-name>
>> >>
>> > <url-pattern>/data/rawData</url-pattern>
>> >>
>> > </servlet-mapping>
>> >
>> >
>> > even if i try to call the servlet directly (direct writing the url in the
>> > address bar) there is no call going to servlet, rather the struts action is
>> > being called. here is the mapping for that stuts action
>> >
>> > <package name="reports" namespace="/report" extends="json-default">
>> >>
>> > <action name="rawList" class="com.e2e.pin.web.actions.RawListAction">
>> >>
>> > <result type="json">
>> >>
>> > <param name="contentType">text/plain</param>
>> >>
>> > <param name="noCache">true</param>
>> >>
>> > </result>
>> >>
>> > <interceptor-ref name="basicStack"/>
>> >>
>> > </action>
>> >>
>> > </package>
>> >
>> >
>> > no matter if i call servlet directly or indirectly, my call never reaches to
>> > the servlet. how can i do this?
>> >
>> > ..alee
>> > http://techboard.wordpress.com
>> >
>> >
>> >
>> > On Wed, Feb 4, 2009 at 1:36 PM, Nils-Helge Garli Hegvik <ni...@gmail.com>wrote:
>> >
>> >> >
>> >> > What should i do ?
>> >>
>> >> You could start by providing some more information. How do call the
>> >> servlet, and how is it configured? Do you get any errors in your log
>> >> files? Can you invoke the servlet by typing it's url in the browser?
>> >>
>> >> Nils-H
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> For additional commands, e-mail: user-help@struts.apache.org
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>
> _________________________________________________________________
> See how Windows connects the people, information, and fun that are part of your life.
> http://clk.atdmt.com/MRT/go/msnnkwxp1020093175mrt/direct/01/

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


RE: [S2] Creating and calling a servlet in sturts2 app

Posted by Andy <an...@hotmail.com>.
I ran into the same thing as the OP.  I think the FilterDispatcher is catching all requests to the servlet since it uses a url-mapping of /*.

 

The Struts in Action book, from what I remember, suggests having an Action receive the request and then dispatch to a servlet.

 

If anyone has direct experience with this please let us know.

 


 
> Date: Wed, 4 Feb 2009 13:01:10 +0100
> Subject: Re: [S2] Creating and calling a servlet in sturts2 app
> From: nilsga@gmail.com
> To: user@struts.apache.org
> 
> I'm not sure I follow you. Are you saying that when you try to invoke
> the servlet, the struts action is invoked instead? Or is nothing
> invoked? And again, have you checked your logs for errors or any
> traces of what's happening? Maybe your servlet is not correctly
> configured so it's not started?
> 
> Nils-H
> 
> On Wed, Feb 4, 2009 at 11:20 AM, alee amin
> <ma...@gmail.com> wrote:
> > This is the entry that i made in web.xml for the servlet
> >
> >> <servlet>
> >>
> > <description>
> >>
> > </description>
> >>
> > <display-name>rawData</display-name>
> >
> > <servlet-name>rawData</servlet-name>
> >>
> > <servlet-class>com.e2e.servlet.rawData</servlet-class>
> >
> > </servlet>
> >>
> > <servlet-mapping>
> >>
> > <servlet-name>rawData</servlet-name>
> >>
> > <url-pattern>/data/rawData</url-pattern>
> >>
> > </servlet-mapping>
> >
> >
> > even if i try to call the servlet directly (direct writing the url in the
> > address bar) there is no call going to servlet, rather the struts action is
> > being called. here is the mapping for that stuts action
> >
> > <package name="reports" namespace="/report" extends="json-default">
> >>
> > <action name="rawList" class="com.e2e.pin.web.actions.RawListAction">
> >>
> > <result type="json">
> >>
> > <param name="contentType">text/plain</param>
> >>
> > <param name="noCache">true</param>
> >>
> > </result>
> >>
> > <interceptor-ref name="basicStack"/>
> >>
> > </action>
> >>
> > </package>
> >
> >
> > no matter if i call servlet directly or indirectly, my call never reaches to
> > the servlet. how can i do this?
> >
> > ..alee
> > http://techboard.wordpress.com
> >
> >
> >
> > On Wed, Feb 4, 2009 at 1:36 PM, Nils-Helge Garli Hegvik <ni...@gmail.com>wrote:
> >
> >> >
> >> > What should i do ?
> >>
> >> You could start by providing some more information. How do call the
> >> servlet, and how is it configured? Do you get any errors in your log
> >> files? Can you invoke the servlet by typing it's url in the browser?
> >>
> >> Nils-H
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
See how Windows connects the people, information, and fun that are part of your life.
http://clk.atdmt.com/MRT/go/msnnkwxp1020093175mrt/direct/01/

Re: [S2] Creating and calling a servlet in sturts2 app

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
I'm not sure I follow you. Are you saying that when you try to invoke
the servlet, the struts action is invoked instead? Or is nothing
invoked? And again, have you checked your logs for errors or any
traces of what's happening? Maybe your servlet is not correctly
configured so it's not started?

Nils-H

On Wed, Feb 4, 2009 at 11:20 AM, alee amin
<ma...@gmail.com> wrote:
> This is the entry that i made in web.xml for the servlet
>
>> <servlet>
>>
> <description>
>>
> </description>
>>
> <display-name>rawData</display-name>
>
> <servlet-name>rawData</servlet-name>
>>
> <servlet-class>com.e2e.servlet.rawData</servlet-class>
>
> </servlet>
>>
> <servlet-mapping>
>>
> <servlet-name>rawData</servlet-name>
>>
> <url-pattern>/data/rawData</url-pattern>
>>
> </servlet-mapping>
>
>
> even if i try to call the servlet directly (direct writing the url in the
> address bar) there is no call going to servlet, rather the struts action is
> being called. here is the mapping for that stuts action
>
> <package name="reports" namespace="/report" extends="json-default">
>>
>  <action name="rawList" class="com.e2e.pin.web.actions.RawListAction">
>>
> <result type="json">
>>
> <param name="contentType">text/plain</param>
>>
> <param name="noCache">true</param>
>>
> </result>
>>
>      <interceptor-ref name="basicStack"/>
>>
>    </action>
>>
> </package>
>
>
> no matter if i call servlet directly or indirectly, my call never reaches to
> the servlet. how can i do this?
>
> ..alee
> http://techboard.wordpress.com
>
>
>
> On Wed, Feb 4, 2009 at 1:36 PM, Nils-Helge Garli Hegvik <ni...@gmail.com>wrote:
>
>> >
>> > What should i do ?
>>
>> You could start by providing some more information. How do call the
>> servlet, and how is it configured? Do you get any errors in your log
>> files? Can you invoke the servlet by typing it's url in the browser?
>>
>> Nils-H
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>

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


Re: [S2] Creating and calling a servlet in sturts2 app

Posted by alee amin <ma...@gmail.com>.
This is the entry that i made in web.xml for the servlet

> <servlet>
>
<description>
>
</description>
>
<display-name>rawData</display-name>

<servlet-name>rawData</servlet-name>
>
<servlet-class>com.e2e.servlet.rawData</servlet-class>

</servlet>
>
<servlet-mapping>
>
<servlet-name>rawData</servlet-name>
>
<url-pattern>/data/rawData</url-pattern>
>
</servlet-mapping>


even if i try to call the servlet directly (direct writing the url in the
address bar) there is no call going to servlet, rather the struts action is
being called. here is the mapping for that stuts action

<package name="reports" namespace="/report" extends="json-default">
>
  <action name="rawList" class="com.e2e.pin.web.actions.RawListAction">
>
<result type="json">
>
<param name="contentType">text/plain</param>
>
<param name="noCache">true</param>
>
</result>
>
      <interceptor-ref name="basicStack"/>
>
    </action>
>
</package>


no matter if i call servlet directly or indirectly, my call never reaches to
the servlet. how can i do this?

..alee
http://techboard.wordpress.com



On Wed, Feb 4, 2009 at 1:36 PM, Nils-Helge Garli Hegvik <ni...@gmail.com>wrote:

> >
> > What should i do ?
>
> You could start by providing some more information. How do call the
> servlet, and how is it configured? Do you get any errors in your log
> files? Can you invoke the servlet by typing it's url in the browser?
>
> Nils-H
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: [S2] Creating and calling a servlet in sturts2 app

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
>
> What should i do ?

You could start by providing some more information. How do call the
servlet, and how is it configured? Do you get any errors in your log
files? Can you invoke the servlet by typing it's url in the browser?

Nils-H

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