You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mark <se...@yahoo.com> on 2007/03/30 16:09:47 UTC

problem: accessing object created in servlet from jsp

Hi,
I try to send an object from servlet to jsp using following:
req.setAttribute("NP", target);
...
getServletContext().getRequestDispatcher("/my.jsp").forward(req,
res);


in my.jsp I have:

<% String wa = (String)request.getParameter("NP"); %>

<%if (wa == null) wa = "blank";%>
<% out.print(wa); %>


But it doesn't work :( "blank" always get displayed, which means I'm
not getting the object from request in jsp.

I have Tomcat 5.5.20, Java 1.5.0_10 knoppix 2007-01 with 2.6.19
kernel

Can any body tell how to set an object to be accessable to JSP
without using session.

Thanks,
Mark


 
____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check. 
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html 

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: problem: accessing object created in servlet from jsp

Posted by Hassan Schroeder <ha...@gmail.com>.
On 3/30/07, Mark <se...@yahoo.com> wrote:

> I try to send an object from servlet to jsp

> <%if (wa == null) wa = "blank";%>

> But it doesn't work :( "blank" always get displayed, which means I'm
> not getting the object from request in jsp.

Or the object really is null :-)

Does it show up if you put it in the session instead?

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: problem: accessing object created in servlet from jsp

Posted by Mark <se...@yahoo.com>.
Oh, what a typo!
Thanks a lot!

Mark
--- Mikolaj Rydzewski <mi...@ceti.pl> wrote:

> Mark wrote:
> > req.setAttribute("NP", target);
> > [...]
> > <% String wa = (String)request.getParameter("NP"); %>
> >   
> They simpy do not match ;-)
> Use request.getAttribute() instead.
> 
> -- 
> Mikolaj Rydzewski <mi...@ceti.pl>
> 
> 



 
____________________________________________________________________________________
The fish are biting. 
Get more visitors on your site using Yahoo! Search Marketing.
http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: problem: accessing object created in servlet from jsp

Posted by Mikolaj Rydzewski <mi...@ceti.pl>.
Mark wrote:
> req.setAttribute("NP", target);
> [...]
> <% String wa = (String)request.getParameter("NP"); %>
>   
They simpy do not match ;-)
Use request.getAttribute() instead.

-- 
Mikolaj Rydzewski <mi...@ceti.pl>


Re: Static class across multiple tomcats?

Posted by or...@kewlstuff.co.za.
I think sharing a common class across servlets can get tricky... I've never 
tried it using Tomcats intrinsic technology, but I think if you if you want 
to go this way then read up on
the ServletContextListener. Lets you look at what other servlets are up to, 
so you could make something that looks at servlet 1 and if it hasnt made the 
common resource then, servlet 2 will make it... then when servlet 1 starts 
it checks servlet 2, see's its already running and uses that.... mmmmmm I 
dont like it, think code could get very messy.

What I do for for this kind stuff is use Harbor....

So I would make the shared class, dump it in the Harbor servlet and then 
call it from other servlets... Harbor is a very lite application server. I 
wrote Harbor and I'm keen to test it on this sort of application, so if you 
care to give me the test code of your shared object, I make 2 servlets and 
show you how to share the object across all your servlets.... even if they 
run on different machines. If you interested have a look at 
http://coolese.100free.com/

regards,
Johnny



----- Original Message ----- 
From: "James Sherwood" <js...@rgisolutions.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Friday, March 30, 2007 4:19 PM
Subject: Static class across multiple tomcats?


> Hello,
>
> What I am trying to do is to have a thread running to check a database for 
> something at a certian time.
>
> All is well but when we launch both tomcats, there are 2 threads running 
> and I cannot figure out how to have only 1 thread running as it seams 
> static classes are unique to each tomcat.
>
> Any ideas?
> Thanks,
> James
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Static class across multiple tomcats?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

James,

James Sherwood wrote:
> All is well but when we launch both tomcats, there are 2 threads running
> and I cannot figure out how to have only 1 thread running as it seams
> static classes are unique to each tomcat.

It sounds like you want something that is entirely outside of either of
the webapps, then.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGDTxt9CaO5/Lv0PARArAEAJ9PEdv6cOZ34GuSpgrM5vhyUQ+EzwCfT8vt
Oz8PlADEajUAZ4Rtq5nyvKQ=
=QUF4
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Static class across multiple tomcats?

Posted by James Sherwood <js...@rgisolutions.com>.
Hello,

What I am trying to do is to have a thread running to check a database for 
something at a certian time.

All is well but when we launch both tomcats, there are 2 threads running and 
I cannot figure out how to have only 1 thread running as it seams static 
classes are unique to each tomcat.

Any ideas?
Thanks,
James 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org