Solved

jsp  pageContext.findAttribute method

Posted on 2013-01-29
9
1,134 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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
 
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
ArrayIndexOutOfBoundException 9 83
servlet  URL Rewriting 1 37
Windows 10 and JDK 7 7u85 4 43
iterator/ListIterator approach 17 27
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 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 …

803 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