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

request.getAttribute returns blank

Dhanaji Patil
Greenhorn

Joined: Mar 31, 2011
Posts: 8
Hi All,

We are migrating our application from Weblogic 9.2 to 10.3.4. I have the below code in java script which runs fine in 9.2 and returns null if attribute is not found in request.

<script type="text/javascript">
var mesg = '<%=request.getAttribute("AlertMsg")%>';
if(mesg != 'null'){
alert(mesg);
}
</script>

But in Weblogic 10.3.4, it returns ' ' (blank space) instead of null. Do i need to add any jar other than weblogic? Why the behaviour is like this? Please guide. Thanks in advance.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

If the parameter doesn't exist then it should return null, if it exists but does not have a value then it should return the empty string.
Check how you call that page and see which is the correct behaviour.
Dhanaji Patil
Greenhorn

Joined: Mar 31, 2011
Posts: 8
Thanks David. But it is giving blank string even though the parameter doesn't exist. In weblogic 9.2, it was giving null for both the cases.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

it is possibly a bug in Weblogic, although not one that I have seen in other application servers before.
My suggestion is to double check that this is the case then contact Oracle if you're sure, or see if there is a patch or more recent version of that server available.
It would also be useful if you were able to verify that it works as expected in other servers eg Tomcat.
Dhanaji Patil
Greenhorn

Joined: Mar 31, 2011
Posts: 8
Thanks a lot David. Will check for the alternatives. Meanwhile if you find anything related to this, then please update. Thanks again.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Dhanaji Patil wrote:Thanks David. But it is giving blank string even though the parameter doesn't exist.


Parameter? But you're using getAttribute() to access it. Request parameters and request attributes are not the same thing.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Ha! Thanks for the second set of eyes, Paul
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: request.getAttribute returns blank