aspose file tools*
The moose likes Servlets and the fly likes Wrong output. Whats wrong?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Wrong output. Whats wrong??" Watch "Wrong output. Whats wrong??" New topic
Author

Wrong output. Whats wrong??

Mamu Jan
Ranch Hand

Joined: Sep 21, 2005
Posts: 45
Hi,

I have two Servlets. The first one is :



For the above servlet I get the following output in the browser:



I get the following output for the above servlet

You are now in Servlet 6 The time in Servlet 5 is : null


Why is it showing null as the value??

I know this whole thing can be easily done using ServletContext but I'm just trying it out using include.

Thanx in advance

[ September 26, 2005: Message edited by: Mamu Jan ]

[ Broke up long line and fixed typo in title ]
[ September 27, 2005: Message edited by: David O'Meara ]

There is no patch for ignorance...
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

If the servlets are run as a result of different requests, then the attribute you write in one will not exist in the other. You either need to place it on the session (not always a good idea), or write the value to the first page and get it to pass it back to the second servlet.

Dave
Mamu Jan
Ranch Hand

Joined: Sep 21, 2005
Posts: 45

or write the value to the first page and get it to pass it back to the second servlet.


How can I do this?? Can anyone show me an example??
[ September 27, 2005: Message edited by: Mamu Jan ]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

The trick is to get the client to pass the information back to the Servlet, at which point it becomes available in the request. It gets passed as a parameter in the request, not an attribute.


[ September 27, 2005: Message edited by: David O'Meara ]
Manikandan Jayaraman
Ranch Hand

Joined: Sep 15, 2004
Posts: 230
Dear David,

Can you please explain, how in this code, you see a new request and response object. We have passed the same request and response objects from servlet5 to servlet6. Right?

I have a similar example tried out in my PC and it worked fine that time. I have done chaining between 3 servlets and it worked perfectly fine.

Putting the code here will bloat the entire write up. So stopping from doing that.

I feel that the code should work fine!

Please explain, if otherwise!

Thanks!
Mani


Regards,<br />Mani<br />SCJP 1.4 (95%)<br />SCWCD 1.4 (94%)
 
wood burning stoves
 
subject: Wrong output. Whats wrong??