Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

jsp pageContext.findAttribute method

I would like to know more about jsp  pageContext.findAttribute method. I would like to know where, when, how, why we use it. I am not able to find good examples on it.
Please advise. Any ideas, sample code, resources highly appreciated. Thanks
in advance.
Avatar of Valeri
Valeri
Flag of Bulgaria image

Avatar of gudii9

ASKER

no link
Avatar of gudii9

ASKER

I ran this example from below link

http://82.157.70.109/mirrorbooks/javaserverpages24hours/0672325977_ch08lev1sec3.html


I have not understood the output i got as below

This page has access to the following attributes:
In the Page scope:
javax.servlet.jsp.jspConfig: org.apache.catalina.core.StandardWrapperFacade@106daba
javax.servlet.jsp.jspResponse: org.apache.catalina.connector.ResponseFacade@1021f34
javax.servlet.jsp.jspPageContext: org.apache.jasper.runtime.PageContextImpl@4eb043
javax.servlet.jsp.jspSession: org.apache.catalina.session.StandardSessionFacade@163956
javax.servlet.jsp.jspRequest: org.apache.catalina.connector.RequestFacade@10e434d
javax.servlet.jsp.jspApplication: org.apache.catalina.core.ApplicationContextFacade@16477d9
javax.servlet.jsp.jspPage: org.apache.jsp.MyJsp_jsp@f864fe
javax.servlet.jsp.jspOut: org.apache.jasper.runtime.JspWriterImpl@1ae9aaa

In the Request scope:

In the Session scope:

In the Application scope:
org.apache.catalina.WELCOME_FILES: [Ljava.lang.String;@2c17f7
javax.servlet.context.tempdir: C:\Users\ganesha\Workspaces\MyEclipse 10_workspace\.metadata\.me_tcat\work\Catalina\localhost\LoginApp
org.apache.catalina.jsp_classpath: /C:/Users/ganesha/Workspaces/MyEclipse%2010_workspace/.metadata/.me_tcat/webapps/LoginApp/WEB-INF/classes/;/C:/Users/ganesha/Workspaces/MyEclipse%2010_workspace/.metadata/.me_tcat/webapps/LoginApp/WEB-INF/lib/javax.servlet.jsp.jstl.jar;/C:/Users/ganesha/Workspaces/MyEclipse%2010_workspace/.metadata/.me_tcat/webapps/LoginApp/WEB-INF/lib/jsf-api.jar;/C:/Users/ganesha/Workspaces/MyEclipse%2010_workspace/.metadata/.me_tcat/webapps/LoginApp/WEB-INF/lib/jsf-impl.jar;/C:/Users/ganesha/Workspaces/MyEclipse%2010_workspace/.metadata/.me_tcat/webapps/LoginApp/WEB-INF/lib/jstl-impl.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.ws.xfire_9.0.0.me201211011550/lib/webservices-api.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.ws.xfire_9.0.0.me201211011550/lib/webservices-extra-api.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.ws.xfire_9.0.0.me201211011550/lib/webservices-extra.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.ws.xfire_9.0.0.me201211011550/lib/webservices-rt.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.ws.xfire_9.0.0.me201211011550/lib/webservices-tools.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/lib/;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/lib/annotations-api.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/lib/catalina-ant.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/lib/catalina-ha.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/lib/catalina-tribes.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/lib/catalina.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/lib/el-api.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/lib/jasper-el.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/lib/jasper-jdt.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/lib/jasper.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/lib/jsp-api.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/lib/servlet-api.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/lib/tomcat-coyote.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/lib/tomcat-dbcp.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/lib/tomcat-i18n-es.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/lib/tomcat-i18n-fr.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/lib/tomcat-i18n-ja.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550/tomcat/bin/bootstrap.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/lib/tools.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/ext/dnsns.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/ext/localedata.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/ext/sunjce_provider.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/ext/sunmscapi.jar;/C:/Users/ganesha/AppData/Local/MyEclipse/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/ext/sunpkcs11.jar
org.apache.jasper.runtime.JspApplicationContextImpl: org.apache.jasper.runtime.JspApplicationContextImpl@d9896e
org.apache.catalina.resources: org.apache.naming.resources.ProxyDirContext@1cda59b
org.apache.AnnotationProcessor: org.apache.catalina.util.DefaultAnnotationProcessor@33788d






can you please explain.

why are they setting scopes to array.

why only request  and session scopes coming in output as below.

In the Request scope:

In the Session scope:

 why not applicaion scope
Avatar of gudii9

ASKER

is there is any other simple exaple to try please advise
Avatar of gudii9

ASKER

i could not find any good examples. please advise
The above example are some basic understanding examples . Can you clearly tell what kind of example you expect ?
ASKER CERTIFIED SOLUTION
Avatar of Valeri
Valeri
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

>>> If for example you put some attribute in the session scope, for example : session.setAttribute("user", someUserObject); it has to be shown there.



I am looking for simple example which uses
pageContext.findAttribute



Can you please advise. Above example is still not clear why they are setting scopes( i thought scopes are implicit right, what is the necessity of declaring and assigning seperately) and then scope names and then simply printing.






How can i modify above code to make it more meaningful. Please advise