Solved

jsp  pageContext.findAttribute method

Posted on 2013-01-29
9
1,107 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
Comment Utility
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
Comment Utility
0
 
LVL 7

Author Comment

by:gudii9
Comment Utility
no link
0
 
LVL 7

Author Comment

by:gudii9
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 7

Author Comment

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

Author Comment

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

Expert Comment

by:Sathish David Kumar N
Comment Utility
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
Comment Utility
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
Comment Utility
>>> 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

763 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

7 Experts available now in Live!

Get 1:1 Help Now