the portlet-instance contains :
use [ code ] [ / code] with no space to write markup
Didn't you mean"
String pref = null; pref = request.getPreferences().getValue("name", "foo"); System.out.println(pref);
You are not setting up pref...
I put following in portlet-instance.xml
<preferences> <preference> <name>name</name> <value>mohan</value> </preference> </preferences>
so the preferences are already set i just want to
fetch their value in java code.
And what's wrong in the code i wrote ?
The java code works if i put
<preferences> .... </preferences>
in portlet.xml but if i put preferences in portlet-instance.xml it gives me null instead of giving value of preference.
You can set up preferences in portlet-instances.xml (note the 's' at the end).
Show more of your portlet-instances.xml file. You can also look at the NewsPortlets in core-samples to see it used.