aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Getting Junk Values While overridding jspInit() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "Getting Junk Values While overridding jspInit()" Watch "Getting Junk Values While overridding jspInit()" New topic
Author

Getting Junk Values While overridding jspInit()

Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643

output is
Key: fork //junk
Value: null
Key: xpoweredBy //junk
Value: null
Key: AdminName //init param from web.xml
Value: null
Key: AdminEmail//init param from web.xml
Value: null

Above is web.xml and JspInitTest.jsp file that overrides jspInit
method.jspInit method reads AdminName and AdminEmail params
from web.xml file but output shows junk value i am not able to understand why.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14671
    
  11

Remove the double quotations in application.getInitParameter("mykey").


About fork and xpoweredBy, those are set by your container. Are you using Tomcat ? Look in the conf/web.xml file, and you'll find them.
[ September 06, 2006: Message edited by: Satou kurinosuke ]

[My Blog]
All roads lead to JavaRanch
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
i Remove the double quotations still output is same.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14671
    
  11

I've edited my first message. Please read again
Shivani Chandna
Ranch Hand

Joined: Sep 18, 2004
Posts: 380
Just a min,

getAttribute(Sting attributeName) returns Object.
and
getAttributeNames() returns Enumeration of attribute names.


/** Code speaks louder than words */
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14671
    
  11

Shivani,
He has previously done "ct.setAttribute("myEmum",myEmum);" so he will get an Enumeration back with getAttribute.
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
Yes i am using Tomcat and i got fork and xpoweredBy in conf/web.xml
But o/p is still same
Where is problem i am not able to understand.
Vikrant Pandit
Ranch Hand

Joined: Mar 27, 2006
Posts: 245


Hi Gowher,

Two important things that will help you to fix this problem

1) Since you are configuring init parameters for jsp,
you need to use
out.print("Value: "+getServletConfig().getInitParameter(mykey))

2) Using Enumeration does not seem to be correct way to implement your logic

Once you have retrieved the Enumeration , it will run for only for one iteration . Next time you try to use this enumeration , it will not return any values

HTH
[ September 06, 2006: Message edited by: Vivek Pandey ]

Vikrant Pandit
Mohd Fuzail
Ranch Hand

Joined: Feb 20, 2002
Posts: 107
I think i got the root cause



If we access the JSP using this pattern then config parameters will be available (via context parameters as we are adding to it)

If we try to access directly using JSP file name then those config init parameters won't be available to the JSP

the output will be if we use /init.do

Key: fork
Value: false
Key: xpoweredBy
Value: false
Key: AdminName
Value: Gowher
Key: AdminEmail
Value: Gowher@rediffmail.com


remember we added out config parameter to context parameters, which already had fork and xpoweredBy


Being defeated is often a temporary condition. Giving up is what makes it permanent.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting Junk Values While overridding jspInit()
 
Similar Threads
overriding jspInit() problem
servlet init parameters for jsp
JSP Init Param
i get ' null ' for jsp init params
JSP init parameters.