Solved

jsp  pageContext.findAttribute method

Posted on 2013-01-29
9
1,123 Views
Last Modified: 2013-03-06
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.
0
Comment
Question by:gudii9
  • 5
  • 2
  • 2
9 Comments
 
LVL 16

Expert Comment

by:Valeri
ID: 38834320
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 38834648
0
 
LVL 7

Author Comment

by:gudii9
ID: 38835276
no link
0
 
LVL 7

Author Comment

by:gudii9
ID: 38835803
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
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 7

Author Comment

by:gudii9
ID: 38837756
is there is any other simple exaple to try please advise
0
 
LVL 7

Author Comment

by:gudii9
ID: 38856173
i could not find any good examples. please advise
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 38858355
The above example are some basic understanding examples . Can you clearly tell what kind of example you expect ?
0
 
LVL 16

Accepted Solution

by:
Valeri earned 500 total points
ID: 38868157
the output of the example shows attributes in the different scopes.
Request and Session sections are empty, because you still have not put any attributes in this scopes. If for example you put some attribute in the session scope, for example : session.setAttribute("user", someUserObject); it has to be shown there.
That is the meaning - example loops through all kind of scopes and shows the attributes in each one of them. Hope it will help you.
0
 
LVL 7

Author Comment

by:gudii9
ID: 38873009
>>> 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
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
solarwind tftp server 2 45
Need to track down Infection in a Server 2008 domain user profile 7 48
Java Loop 6 50
fibonacci ten numbers 4 30
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

30 Experts available now in Live!

Get 1:1 Help Now