Session variable in 'rendered' tag
Hello,
I would like to use a session variable to control whether a component is rendered or not.
My idea looks like this:
<h:outputText value=" #{p.p.ql}" rendered="#{p.p.ql == ' <%= session variable here %> ' }" />the synthax ' <%= session variable here %> ' is not correct and does not work.
Can a session variable be used this way ? What is the correct way to write this ?
Thank you very much.
ed
Message was edited by: ediestel
ediestel
Message was edited by:
ediestel
in jsf you can set whether a tag is rendered or not, so it is not a renderd 'tag' but rather an 'attribute' to a tag.
Similar Messages
-
How to access a session variable just before rendering a JSF page???
Dear Sirs...
i am using jdeveloper 10.1.3.2 with JSF and ADF faces. i want to access a session variable and perform some processing just before rendering a page. how can i achieve this????
i am a little new to jsf, so i feel a little lost
thanks for any help in advance, and best regards<p>
Hi,
</p>
<p>
See example 60 "<strong>Triggering OnPageLoad-Style Code in a JSF Backing Bean Using ADF PagePhaseListener or PageController</strong>" on Steve's Muench blog.
</p>
<p>
Kuba
</p> -
Are session variables available at custom tags ?
Are the variables that I put into the session available at cutom tag classes ?
Thanks
EliHi elibarnett,
1. yes, you get it via the javax.servlet.jsp.PageContext class.
2. For example:
public int doStartTag()
javax.servlet.http.HttpSession session = pageContext.getSession();
-- Paul. -
Having an issue with passing the text of a link to a session variable.
I am having an issue with passing the text from a link to a session variable. I am adding this html as a literal for each item in the list that i have populated with a query.
List<Literal> lit = new List<Literal>();
for (int i = 0; i < posts.Count; i+=4)
Literal someLit = new Literal();
someLit.Text=
@"<div class='row'>" +
"<div class='col-md-12'>" +
"<div class='panel'>" +
" <div class='panel-body'>" +
" <!--/stories-->" +
" <div class='row'> " +
" <br>" +
"<div class='col-md-2 col-sm-3 text-center' id='javascript'> <h3>" +
" <a href='#' runat='server' onserverclick='UserProfile_Click'>" + posts[i + 3] + " </a>" +
"</h3>" +
" </div>" +
" <div class='col-md-10 col-sm-9'>" +
"<h3><a href='Thread.aspx' runat='server' onserverclick='MyFuncion_Click'> " + posts[i] + " </a></h3>" +
" <div class='row'>" +
" <div class='col-xs-9'> " +
posts[i + 1] +
" </div>" +
"<div class='col-xs-3'></div>" +
posts[i + 2] +
" </div>" +
"<br><br>" +
" </div>" +
" </div>" +
" <!--/stories-->" +
" </div>" +
" </div>" +
" </div><!--/col-12-->" +
" </div>" +
"</div>";
lit.Add(someLit);
for(int i=0; i<lit.Count; i++)
this.Controls.Add(lit[i]);
I use one of the list positions as the text for a link in two different spots. For now, lets only talk about the line:
<a href='#' runat='server' onserverclick='UserProfile_Click'>" + posts[i + 3] + " </a>
Since I am generating these controls at pageLoad, I can't make them <asp:Linkbutton>s. And since they are anchor elements, I don't have access to an onCommand attribute or onservercommand attribute.
All I want to do is access the content from inside the specific link tags that I generate on link click and set it as a session variable. That's what I would like my UserProfile_Click function to do. I cant commandargs it in like i can with a linkbutton's
OnCommnad attribute, however.
My fear is that the onserverclick attribute resolves so something else on pageLoad normally and since I am generating it the way I am similar to the way a <asp:linkButton> resolves to a generated JavaScript.
Any help?@Brunellus
For questions related to ASP.NET use the ASP.NET forum http://forums.asp.net
You should get more, better and faster answers on the other forum. Thanks, ahead of time.
Best Regards,
Kristin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Personalization Server: Reference session variable in cm:select
<%=String X=(String)session.getAttribute(y)%>
How do we get X into a cm:select tag?
I attempting to do a query and want to pass X into it.
Tried doing <%=X%> and it's causing a JSP compile error.
So, I guess I need to know how to pass a session variable into the query of a CM:SELECT
tag?
Thanks,
MarkHello Mark,
A coworker of mine created a sample that I tested with an in-lined String variable for
the "query" attribute. It works fine. I suspect that you may have other problems. For
instance, I don't think <%= String X=(String)session.getAttribute(y)%> is legal. The <%=
%> is supposed to contain a java expression, like <%= (String) session.getAttribute(y) %>
Also, double-quotes within an expression can be problematic, such as <%= (String)
session.getAttribute("y") %>. The best way to handle this would be to assign the session
attribute to a String and then inline the String with: <%= myValue %>.
Here is a working sample (that does not use a session variable, but that does not matter
- it uses a String:
<!-- Import the content management tag -->
<%@ taglib uri="cm.tld" prefix="cm" %>
<%@ taglib uri="es.tld" prefix="es" %>
<%@ page import="com.beasys.commerce.content.ContentHelper" %>
<!-- Use the cm:select tag to query the example content files in
<drive>:\weblogiccommerce3.2\dmsBase for type = news, (see headline1.htm,
headline2.htm, headline3.htm, headline4.htm, business1.htm, sports1.htm,
and showbiz1.htm) and display headings -->
<br>
<%
String newsQuery = "type = 'news'";
%>
<cm:select contentHome="<%=ContentHelper.DEF_CONTENT_MANAGER_HOME%>"
query="<%= newsQuery %>"
sortBy="heading ASC"
id="newsline" cacheId="news_lines"
cacheTimeout="300000" useCache="true" />
<es:forEachInArray array="<%=newsline%>"
id="newsBL" type="com.beasys.commerce.axiom.content.Content"
counterId="i">
<br>
<% out.println((i.intValue()+1) + ") "); %>
<cm:printProperty id="newsBL" name="heading" encode="html" default="Error" />
</es:forEachInArray>
Mark Mangano wrote:
<%=String X=(String)session.getAttribute(y)%>
How do we get X into a cm:select tag?
I attempting to do a query and want to pass X into it.
Tried doing <%=X%> and it's causing a JSP compile error.
So, I guess I need to know how to pass a session variable into the query of a CM:SELECT
tag?
Thanks,
Mark--
Ture Hoefner
BEA Systems, Inc.
2590 Pearl St.
Suite 110
Boulder, CO 80302
www.bea.com
[att1.html] -
In my onApplicationStart method (which should tell you I'm
using an Application.cfC, not cfM), I have a cfif loop that passes
a value to a custom tag and returns a form variable. I'm then
reassigning that variable to a session variable. In IE, this works
just fine; in Firefox, though, the session variable is NOT being
set.
What might be causing this, and is there a workaround?The issue referred to an external CF custom tag, which called
another demo application to set a testing user. However, after
further testing, I realize that demo app won't function properly
with this application, so I've removed it.
Authentication is being set by an LDAP query; this
application that I am working on is going to be a sub-application
of a larger application, and the authenticated user is being set as
a session variable as well (I think...). However, I'm creating a
new session variable for this application, and simply passing the
authenticated user into my app (the outer app uses the variable
auth_user; I'm using the variable authuser, so there is no name
conflict).
Again, it is IE that is not persisting the session. Firefox
is doing so. I have looked in the advanced settings for IE, and
there is nothing about persisting session variables to check or
uncheck. Also, this application will probably be used mostly by
users using IE 6 with default settings, so I'm going to need to
find a workaround for IE.
Your help is most appreciated. -
CFLOGIN not maintaining cfauthrization session variable
I have a simple CF web site where all of the .cfm is in the
same directory. I can not use client cookies as the people I am
writing this for have cookies turned off in IE, therefore I am
using J2EE session variables and CFLOGIN in an application.cfm file
(code attached) for authentication. Everything works correctly
during login and I can see the encrypted username/password as the
cfauthorization session variable....
Session Variables:
cfauthorization=Y3BkYWRtaW46cmVwb3J0ODQzOmNwZA==
sessionid=c23059df643c42544069
urltoken=CFID=783&CFTOKEN=91556252&jsessionid=c23059df643c42544069
Once I try to browse to another cfm page on the site, I get
booted back to the index.cfm login page. After some digging I
figure out that the cfauthorization variable was blank after I
click on the link, which as I understand it indicates that I am not
logged in and the
<cfif not IsDefined("cflogin")>
<cfinclude template="index.cfm">
<cfabort>
code in the application.cfm sends me back to the login page.
I have confirmed that using valid credentials causes <cfif
cpdauth.recordcount GT "0"> to return true.
Any idea as to why my session authorization is not being
maintained between pages? Or if I am completely off base as to the
reason this is happening.....and if so, what am I doing wrong.
Thanks
GregYour login code seems to be fine. You yourself are already
aware that you have to have a way to pass-the-baton between
requests, to maintain a session.
The usual way Coldfusion maintains sessions is to send CFID
and CFTOKEN cookies to the client browser. That happens
automatically under the hood, assuming you haven't switched
setClientCookies off.
For session management by means of cookies, I would use a
cfapplication tag like
<cfapplication name = "cpd"
applicationTimeout = "#createTimespan(1,0,0,0)#"
sessionManagement = "yes"
clientManagement = "yes"
sessionTimeout = "#createTimeSpan(0,0,20,0)#"
setClientCookies = "true"
scriptprotect="all"
loginstorage="Session">
However, all of that assumes that the client browser accepts
cookies. Where it doesn't, the usual way to maintain sessions is to
pass CFID and CFTOKEN values in the URL of every request. In fact,
the function that Bluetone suggests,
URLSessionFormat,
makes the process efficient. It instructs Coldfusion to append CFID
and CFTOKEN to the URL only when the client doesn't accept cookies.
Which means Coldfusion would still be using cookies wherever
possible. Some examples
<a href="#URLSessionFormat('orders.cfm')#">My
orders</a>
<cfform method="Post"
action="#URLSessionFormat("MyActionPage.cfm")#">
</cfform>
<cflocation url = "products.cfm" addToken = "yes"> -
Coldfusion session variables being lost
ok so when my users login I establish session variables. one of these is employee id. in my Application.cfc I have this at the top:
<cfscript>
this.name = "My App";
this.sessiontimeout=CreateTimeSpan("0", "0", "45", "0");
this.SESSIONMANAGEMENT="YES";
this.SetClientCookies = "true";
this.setDomainCookies = "true";
</cfscript>
i also set the timeout for sessions at 45 in the CFadmin too.
after a successfull login i capture their session.employeenumber by authenticating through our corporate LDAP. no problem there. note: this app has run smoothly for 6+ years now but something has recently gone wrong.
on every page i reference a file in my application directory called "check_session.cfm" like this:
<cfmodule template="/myApp/Tags/check_session.cfm">
In that file I have code that checks for the existence of the session.employee_number. if it doesn't exist they either timed out or book-marked a page in the app in which they need to be logged in to view:
<cflock timeout="30" throwontimeout="Yes" type="READONLY" scope="SESSION">
<!--- Checks to make sure the user has a session--->
<CFIF NOT IsDefined("Session.employee_number")>
<CFLOCATION URL="http://#cgi.HTTP_HOST#/myApp/LoginAgain.cfm">
</CFIF>
</cflock>
every now and then (i'd say on average 5 times per week) i get an error message from a user (i re-direct all errors to my email with diagnostic info). the error reads "Element EMPLOYEE_NUMBER is undefined in SESSION". when i look at the page the error came from i see my call to the check_session.cfm file about 50 lines above where this error happened when i tried to reference session.employee_number. why wouldn't it not find it and re-direct the user to the timeout page? i can never duplicate this error on my machine either... i always get the right result without the error message. its a random, sporadic, intermittent error.Here is the diagnostic error information. Where you see [omitted] i've changed the URL for the purposes of displaying this detail in a public forum:
struct
Browser
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E; MS-RTC LM 8)
DateTime
{ts '2011-02-21 20:59:21'}
Diagnostics
Element EMPLOYEENUMBER is undefined in SESSION. <br>The error occurred on line 162.
GeneratedContent
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <!-- DW6 --> <head> <!-- Copyright 2005 Macromedia, Inc. All rights reserved. --> <title>My Home</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="mm_training.css" type="text/css" /> <link rel="stylesheet" type="text/css" href="../template/organized.css"> </head> <body bgcolor="#ffffff" onLoad="onInit()">
HTTPReferer
http://[omitted]/mypage/myhome.cfm?CFID=101686&CFTOKEN=53097237
Mailto
[empty string]
Message
Element EMPLOYEENUMBER is undefined in SESSION.
QueryString
[empty string]
RemoteAddress
10.x.x.x [remote address omitted for purposes of this forum]
RootCause
struct
Detail
[empty string]
ErrNumber
0
Message
Element EMPLOYEENUMBER is undefined in SESSION.
Resolvedname
SESSION
StackTrace
coldfusion.runtime.UndefinedElementException: Element EMPLOYEENUMBER is undefined in SESSION. at coldfusion.runtime.CfJspPage.resolveCanonicalName(CfJspPage.java:1659) at coldfusion.runtime.CfJspPage._resolve(CfJspPage.java:1612) at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1747) at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1740) at cfmyhome2ecfm1641837815._factor14(D:\[path_omitted]\mypage\myhome.cfm:162) at cfmyhome2ecfm1641837815.runPage(D:\[path_omitted]\mypage\myhome.cfm:1) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:196) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:370) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:273) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:86) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:2 8) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.CfmServlet.service(CfmServlet.java:175) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at jrun.servlet.FilterChain.doFilter(FilterChain.java:86) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42 ) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at jrun.servlet.FilterChain.service(FilterChain.java:101) at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286) at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543) at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203) at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320) at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428) at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266) at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
TagContext
array
1
struct
COLUMN
0
ID
LINE
162
RAW_TRACE
at cfmyhome2ecfm1641837815._factor14(D:\[path_omitted]\mypage\myhome.cfm:162)
TEMPLATE
D:\[path_omitted]\mypage\myhome.cfm
TYPE
CFML
2
struct
COLUMN
0
ID
CF_MYHOME
LINE
1
RAW_TRACE
at cfmyhome2ecfm1641837815.runPage(D:\[path_omitted]\mypage\myhome.cfm:1)
TEMPLATE
D:\[path_omitted]\mypage\myhome.cfm
TYPE
CFML
Type
Expression
element
EMPLOYEENUMBER
objectType
object of java.lang.Class
Class Name
java.lang.Class
Methods
Method
Return Type
asSubclass(java.lang.Class)
java.lang.Class
cast(java.lang.Object)
java.lang.Object
desiredAssertionStatus()
boolean
forName(java.lang.String, boolean, java.lang.ClassLoader)
java.lang.Class
forName(java.lang.String)
java.lang.Class
getAnnotation(java.lang.Class)
java.lang.annotation.Annotation
getAnnotations()
java.lang.annotation.Annotation[]
getCanonicalName()
java.lang.String
getClassLoader()
java.lang.ClassLoader
getClasses()
java.lang.Class[]
getComponentType()
java.lang.Class
getConstructor(java.lang.Class[])
java.lang.reflect.Constructor
getConstructors()
java.lang.reflect.Constructor[]
getDeclaredAnnotations()
java.lang.annotation.Annotation[]
getDeclaredClasses()
java.lang.Class[]
getDeclaredConstructor(java.lang.Class[])
java.lang.reflect.Constructor
getDeclaredConstructors()
java.lang.reflect.Constructor[]
getDeclaredField(java.lang.String)
java.lang.reflect.Field
getDeclaredFields()
java.lang.reflect.Field[]
getDeclaredMethod(java.lang.String, java.lang.Class[])
java.lang.reflect.Method
getDeclaredMethods()
java.lang.reflect.Method[]
getDeclaringClass()
java.lang.Class
getEnclosingClass()
java.lang.Class
getEnclosingConstructor()
java.lang.reflect.Constructor
getEnclosingMethod()
java.lang.reflect.Method
getEnumConstants()
java.lang.Object[]
getField(java.lang.String)
java.lang.reflect.Field
getFields()
java.lang.reflect.Field[]
getGenericInterfaces()
java.lang.reflect.Type[]
getGenericSuperclass()
java.lang.reflect.Type
getInterfaces()
java.lang.Class[]
getMethod(java.lang.String, java.lang.Class[])
java.lang.reflect.Method
getMethods()
java.lang.reflect.Method[]
getModifiers()
int
getName()
java.lang.String
getPackage()
java.lang.Package
getProtectionDomain()
java.security.ProtectionDomain
getResource(java.lang.String)
java.net.URL
getResourceAsStream(java.lang.String)
java.io.InputStream
getSigners()
java.lang.Object[]
getSimpleName()
java.lang.String
getSuperclass()
java.lang.Class
getTypeParameters()
java.lang.reflect.TypeVariable[]
isAnnotation()
boolean
isAnnotationPresent(java.lang.Class)
boolean
isAnonymousClass()
boolean
isArray()
boolean
isAssignableFrom(java.lang.Class)
boolean
isEnum()
boolean
isInstance(java.lang.Object)
boolean
isInterface()
boolean
isLocalClass()
boolean
isMemberClass()
boolean
isPrimitive()
boolean
isSynthetic()
boolean
newInstance()
java.lang.Object
toString()
java.lang.String
StackTrace
coldfusion.runtime.UndefinedElementException: Element EMPLOYEENUMBER is undefined in SESSION. at coldfusion.runtime.CfJspPage.resolveCanonicalName(CfJspPage.java:1659) at coldfusion.runtime.CfJspPage._resolve(CfJspPage.java:1612) at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1747) at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1740) at cfmyhome2ecfm1641837815._factor14(D:\[path_omitted]\mypage\myhome.cfm:162) at cfmyhome2ecfm1641837815.runPage(D:\[path_omitted]\mypage\myhome.cfm:1) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:196) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:370) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:273) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:86) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:2 8) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.CfmServlet.service(CfmServlet.java:175) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at jrun.servlet.FilterChain.doFilter(FilterChain.java:86) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42 ) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at jrun.servlet.FilterChain.service(FilterChain.java:101) at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286) at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543) at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203) at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320) at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428) at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266) at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
TagContext
array
1
struct
COLUMN
0
ID
LINE
162
RAW_TRACE
at cfmyhome2ecfm1641837815._factor14(D:\[path_omitted]\mypage\myhome.cfm:162)
TEMPLATE
D:\[path_omitted]\mypage\myhome.cfm
TYPE
CFML
2
struct
COLUMN
0
ID
CF_MYHOME
LINE
1
RAW_TRACE
at cfmyhome2ecfm1641837815.runPage(D:\[path_omitted]\mypage\myhome.cfm:1)
TEMPLATE
D:\[path_omitted]\mypage\myhome.cfm
TYPE
CFML
Template
/[omitted]/mypage/myhome.cfm
Type
coldfusion.runtime.CfErrorWrapper -
Access session variable in Java Function in JSP
Hi Experts !!
I am developing an application using STRUTS MVC...
Very sorry if u have problem understanding my question, i ll try to improve... and sorry if i can't post codes here
Basic question is ....
I want to open a word document on pageLoad of JSP, the word document is not a single document, there is a form in which there is a "name" and "template" whenever user clicks on a button there is one action attached to it which creates a copy of that template in a different folder.. on the next page OnLoad i want to open that particular document. for that i have created a variable and also have set in the session, just want to access it in the below code.
I have a formbean in which i have a variable, the scope is session, that variable i have put it in session also. but i want to access that variable in a "java function" in JSP so that "onLoad" page that function should work.
JSP---
<script type="text/javascript">
function openDocument() {
var w = new ActiveXObject("Word.Application");
var docText;
var obj;
var a;
if (w != null) {
w.Visible = true;
obj = w.Documents.Open(I HAVE TO ACCESS THAT VARIABLE HERE);
</script>
FORMBEAN----
public class CreateSOWFormBean extends ActionForm {
private String workflowName;
private String comment;
private String sowTemplate;
private String sowFileCreated;
public String getSowFileCreated() {
return sowFileCreated;
public void setSowFileCreated(String sowFileCreated) {
this.sowFileCreated = sowFileCreated;
sowFileCreated is the variable that i have accessed in session and that value i have to pass in that function in JSP....
I am aware of something like
obj = w.Documents.Open(<%'sowFileCreated'%>);
but i m not sure how to write....
Plz help.....If you're working under a framework like struts you should definitely be using JSTL tags rather than scriptlet code to access variables within the page. With JSTL code <% codes can be almost entirely avoided.
To transfer a value from a Servlet to a JSP don't use a session variable, use a request attribute. Session variables should only be used when values have to survive from one transaction to another.
You can write something like:
obj = w.Documents.open('<c:out value="${openURL}"/>');in the Javascript portion of your JSP.
Just beware of potential problems with quotes. The coresponding code in the Servlet would be like:
request.setAttribute("openURL", openUrl); -
Session Variables Randomly Lost between Pages
My web page uses a session to keep track of who logged in.
What I noticed is that the session variables stored appears and
disappears randomly on different pages. The wierd thing is that my
code is very simple.
For the life of me I can not figure this out....I go through a hosting company and do not expect them to do
any load balancing.
What are sticky sessions?
The cflocation tag also has the addtoken="yes" to it now and
symptoms persist.
I tested the case with
sessiontimeout=#CreateTimeSpan(0,2,0,0)# instead of the
sessiontimeout=#CreateTimeSpan(0,0,120,0)# and symptoms still
persist.
Any other suggestions? I think I ran into a wall
here.... -
Inablility to retrieve values of session variables in irpt page
We currently are using xMII 11.5. We are having difficulty retrieving values assigned to our created session variables.
We have defined 2 users, each associated with session variables whose values differ by user. Each user is associated with a different irpt page which retrieves information based on the values passed by the session variables. Both pages return correct information in the grid using the as the param.1 value on the opening of the page.
On one page, we are able to retrieve the values of the session variables in Javascript by placing hidden fields on the document and using the document.getelementbyID("hiddenValue1").value. The other irpt will only bring back the name of the of the session variable in the curly braces, .
Both users are set up the same in System Security and Data Access. If we switch the pages opened for the user in the Portal Navigation, one page will return the values no matter which user and the other page will always bring back the session variable name in the braces. This makes us believe that it is not a problem with the user setup or the definition of the session variables.
Would anyone be able to help us understand what needs to be done to correct this issue?Michelle,
Have you tried URL encoding your irpt pass through parameters in your Navigation link? Perhaps the commas and parenthesis are causing some issues ( http://help.sap.com/saphelp_xmii115/helpdata/en/Getting_Started/Template_Editor/Query_Construction.htm )
Just to clarify, the Role/User attributes defined in LHSecurity are truly session properties, and the session properties are shown by the PropertyAccessServlet results. Adding the name/value pairs to the URL are only a one-shot pass through to the ReportServlet that processes web pages with .irpt extenstions, so they don't actually set the session properties and are non-retentive beyond the one page. As you are presently doing with the navigation links, we typically recommend URL passthroughs for page to page activities and using the session itself for name/value pairs that you want to set once and use anywhere throughout your application.
document.APPLET.getPropertyValue(NAME); will also give you access to the session through javascript, but if you do a view...source in the browser after your TeamLeaderView web page has loaded you should see the results of the search/replace efforts of the ReportServlet, and the javascript you are using to get values out of hidden form field elements should simply reflect the text you see in the view source window.
If they work inside APPLET tags like you mentioned for Param.1 you could also use document.APPLET.getQueryObject().getParam(1); instead of the hidden form field elements, and remember that you have 32 params and if they are not used in the underlying query can provide a very nice place to 'catch' the results like you are are doing with hidden form field elements that could potentially get reset by a form button.
Regards,
Jeremy -
Problem accessing session variable from jsp
Hi!
I get an error retrieving a session variable from inside a JSP declaration scriptlet....
Something like this code in a JSP page:
<%!
public void funtion1() {
String parameter1 = session.getAttribute("parameter1");
%>I have seen that I have available getContextServer() method and from there I could call getAttribute("parameter1") . But the thing is that the attribute I want to retrieve was stored in session by another Jsp page.
Any solutions are welcome
Cheers
VictorAppropriately the above is one the reasons also You cannot use JSP implicit objects from the declaration tag. However we can think of a small workaround by passing the reference like the one discussed below
<%!public void funtion1(HttpSession session) {
String parameter1 = session.getAttribute("parameter1").toString();
}%>
<% funtion1(session);%>Hope that helps :)
REGARDS,
RaHuL -
hi ,
Is it not correct to assume that ones we close the browser the session losts and all the session variables also?
Actually i have design an authentication page which takes userid and password from user and supply this to servlet which after authentication sets a variable "validity" in session to true.
And in every other jsp page first i m checking this variableis true or not if not then i m redirecting it to authentication page with this tag
<jsp:forward page="authentication.jsp" />
now if i have authenticated correctly and close browser and try to access other pages directly then browser allows me to access any page and infact when i print "validity" variable from session then it prints true. That means even after closing the browsing session remains.
I tried to print session id then after opening a new browser it is showing the same browser.
In web.xml file i have mentioned the session time to 60 minutes . Is it because of this?. If it then how these standard sites sun, yahoo maintains session time out as well as browser dependent session.
Right now what i have to do is before setting the variable i have reset the variable to null. But wher shud i reset the validity variable . in destroy method?
manishYour problem is not due to session time out in the xml
file.
I think whenever you close your browser the session
does not exists.
Remember to invalidate the session while logging off.
It should workThat is not true. The session will exist for as long as the session timout option is set. Although invalidating the session at logoff is a good idea, there is no real method to force people to log off when the leave your site/close the browser.
There are a couple of possibilities why the session would still be used after a browser is closed, although normal behavior is to create a new one. The main reason is because the cookie on the browser that maintains the jsessionid is not destroyed. This often occurs in browsers like NS 7 with a "quick-load" app running in the taskbar area (next to the clock). These little parts of the application never close, and hold on to browser cache and cookies, so as to make it quicker to open and surf.
How do you ge around this? I do not know, except perhaps by preventing the session from using cookies for tracking... -
Please Help Session variables disappear
Hi. I am having issues with the developer's version of CF MX
7. I recently set up the developer's version on a test server, and
moved over code from a properly working site using MX 6. I have an
application.cfm file set will the correct <cfapplication> tag
attributes, and the session management is set in the CF admin. When
working on MX 6 the session variables I set were working. Now using
MX 7 none of my sessions are holding. When I first login the
sessions exist, if I click any other page, the variables disappear.
Again, this does not happen on MX 6.
Please help!
Thanks,
jlgDouble-check your sessiontimemout
Try setting up a simple test application using something
similar to the example at
http://livedocs.adobe.com/coldfusion/7/htmldocs/00000217.htm -
What is session variables in BSP
Hi
I am using using IC Webclient. can anyone help me to findout the details about session varibales ?
Best Regards
Bhavishyahi,
Session variables is a handy way to define a persistent variable.The standard variables used in ColdFusion can be only transferred or sent to the next page before it is necessary to restate the variable. In some situations, you may want to define a variable that will apply to all the pages during a single session of the user. An example is when the pages a user sees are personalized to his or her specific needs. In such a case, session variables are defined and used.
Session variable persistent
A session variable is one of several types of variables that persist across multiple templates:
>Server variables - Accessible by all clients and applications on a single
>Application variables - Tied to a single application and accessible by multiple clients
>Client variables - Tied to a single client over multiple sessions
>Session variables - Exist for one client or browser during a single session
>Cookie variables
Session variables are designed to hold information that you seldom write but are read often.
Defining session variables
Session variables are normally defined in the Application template, but can be also defined on all applicable pages.
Application template
The standard method of using session variables is to define them in the application.cfm template, which is a special ColdFusion page that is processed before the other pages in a session. It usually should be in the session root directory.
CFAPPLICATION tag
To enable the use of session variables, as well as client and application management, you should use the CFAPPLICATION tag in the Application template. A typical tag would be:
<CFAPPLICATION NAME="Name"
SESSIONMANAGEMENT="Yes"
SESSIONTIMEOUT="#CreateTimeSpan(0, 0, 20, 0)#">
where:
>NAME is required to avoid problems if you have session variables tied to separate applications.
>SESSIONMANAGEMENT is required to enable the session variables.
>SESSIONTIMEOUT is optional and limits the time the variables will stay in memory (20 minutes in the example) Note that the default is 20 minutes, so you really may not need this unless you want to change that number.
Setting variables
After the CFAPPLICATION tag, you can set your session variables, using the CFSET tag. You must always refer to session variables with the prefix session. Thus, you could define a session variable, such as:
<CFSET session.name="#form.othername#">
Should lock variables
You should lock the session variables to avoid problems when several people are using the system at the same time. An example of this is:
<CFLOCK TIMEOUT="30" NAME="#session.sessionID#" TYPE="Exclusive">
<CFSET session.name="#form.othername#">
</CFLOCK>
Defined on applicable pages
A problem in using the Application.cfm template is that it is often difficult to change your session variables, once they have been set. An alternative is to use the CFAPPLICATION tag in each applicable page:
<CFAPPLICATION NAME="Name"
SESSIONMANAGEMENT="Yes">
You then can define the session variable in the first page, accessed:
<CFOUTPUT QUERY="return">
<CFSET session.ID="#ID#">
</CFOUTPUT>
This is a compromise between the standard method and defining the variable on each page.
Example of use
Suppose a user logged in to the site. His name could be sent through a form and entered in Application.cfm. Then the session will constantly refer to him by name.
Application.cfm
<CFAPPLICATION NAME="Name"
SESSIONMANAGEMENT="Yes">
<CFSET session.name="#form.othername#">
Start.cfm
<CFOUTPUT>
<H1>Hello #session.name#</H1>
</CFOUTPUT>
Maybe you are looking for
-
Question about XML mapping to ABAP internal table
Hi experts. I'm trying to XML mapping. But it doesn't work well. Assume there are XML file as below. <HEADER> <ITEM> <FOO>123</FOO> <BAR>ABC</BAR> </ITEM> <ITEM> <FOO>456</FOO> <BAR>DEF</BAR> </ITEM> <HEADER> and I want to tra
-
Do Mac Mini and Macbook Pro Retina use the exact same i7 processor?
If not why do I get the exact same info from both computers: Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz Processor Speed: 2.3 GHz Number of Processors: 1 Total Number of Cores: 4 L2 Cache (per Core): 256 KB L3 Cache: 6 MB Isn't it strange that they are
-
Trigger CIF during custom field change on Purchase Req. and PO
Hi, We added a custom date field in Purchase Req. and Purchase Order transactions (ME52N/ME22N) in ECC. When this custom field gets changed along with any other standard field, outbound CIF process happens. However, when we change this custom field o
-
Clarification on Incomplete recovery
Hi Friends, Just clarification on 2 Things on incomplete recovery. Undo tablespace (datafiles): I lost current undo tablespace datafile but i have datafiles from backup,archived logs,current control file,online redo log and still can i perform comple
-
Why does "autofill from playlist" not work?
I have tried to autofill music onto my iphone from a playlist, but it will not allow me to, and gives a really unhelpful error message: "iTunes cannot add any songs to the iPhone "x" because no songs in the playlist "x" can be copied to this iPhone."