• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting Junk Values While overridding jspInit()

 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i Remove the double quotations still output is same.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've edited my first message. Please read again
 
Shivani Chandna
Ranch Hand
Posts: 380
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a min,

getAttribute(Sting attributeName) returns Object.
and
getAttributeNames() returns Enumeration of attribute names.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shivani,
He has previously done "ct.setAttribute("myEmum",myEmum);" so he will get an Enumeration back with getAttribute.
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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 ]
 
Mohd Fuzail
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic