Get html session variables.
Hi all,
From the OA Framework I'm calling my ADF application.
THe OApage has set some variables in the html session.
How can I get the values in ADF?
I tried this:
FacesContext fctx = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest)fctx.getExternalContext().getRequest();
HttpSession session1 = request.getSession();
String user_id= (String)session1.getValue("userName");
System.out.println(user_id);
[\code]
That gives me a null value.
On the OAF forum they told me that could be because in the preparesession of AM the html session could be reset.
My question is: How can I get the value of the variable userName that is stored in the htmlsession?
Option 1:
Override the prepareSession() in AM and then get the value? (don't know how because FacesContext is not recognized in Amimpl.java.)
Option 2:
Totally different approach???
Hmmm ... getValue( ) is deprecated but should still work, I believe?! I would use getAttribute( ) instead.
Are you sure the value is in the session? You could breakpoint and examine the attributes in the session using the debugger.
prepareSession() in the AM has nothing to do with the HTML session. I doubt that the AM has even knowledge of HTML stuff.
Sascha
Similar Messages
-
How to get the session variable value in JSF
Hi
This is Subbus, I'm new for JSF framewrok, i was set the session scope for my LoginBean in faces-config.xml file..
<managed-bean-name>login</managed-bean-name>
<managed-bean-class>LoginBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope> like that...
So all parameter in LoginBean are set in session right ?... for example i used userId is the Parameter...
Now i need to get the the userId parameter from that session in my another JSP page.. how i get that ?..
Already i tried
session.getAtrribute("userId");
session.getValue("userId");
but it retrieve only "null" value.. could u please help me.. it's very urgent one..
By
SubbusWhere i use that..is it in jsp or backend bean...
simply i use the following code in one backend bean and try to get the value from there bean in the front of jsp page...
in LogoutBean inside
public String getUserID()
Object sessionAttribute = null;
FacesContext facescontext=FacesContext.getCurrentInstance();
ExternalContext externalcontext=facescontext.getExternalContext();
Map sessionMap=externalcontext.getSessionMap();
if(sessionMap != null)
sessionAttribute = sessionMap.get("userId");
System.out.println("Session value is...."+(String)sessionAttribute);
return (String)sessionAttribute;
return "fail";
JSP Page
<jsp:useBean id="logs" scope="session" class="logs.LogoutBean" />
System.out.println("SS value is ...."+logs.getUserID());
but again it retrieve only null value.. could u please tell me first how to set the session variable in JSF.. i did faces-config only.. is it correct or not..
By
Subbus -
Get loggedin Session variables in Home Page
I got a members directory where u login.
1.How come they get killed when i refresh a page.
2.How do i get the loggedin session variable the home page.
so i know if current user is logged in.
The Application.cfc of the members is
<cfcomponent name="Application" displayname="Application
Component for the Login Security Tutorial" >
<cfset This.name = "NewLoveZoneAfrica">
<cfset This.applicationTimeout =
CreateTimeSpan(0,0,0,45)>
<cfset This.sessionManagement = "true">
<cfset This.sessionTimeout = CreateTimeSpan(0,0,0,30)>
<cfset This.clientManagement = "false">
<cfset This.loginstorage="session">
<cffunction name="onApplicationStart"
returntype="boolean" output="true">
<!--- Set up Application variables. Locking the
Application scope is not necessary in this method. --->
application starting
<cfset Application.configured = 1>
<cfset Application.datetimeConfigured = TimeFormat(Now(),
"hh:mm tt") & " " & DateFormat(Now(), "mm.dd.yyyy")>
<cfset Application.currentSessions = 0>
<!--- Begin Setting up request variables here. --->
<cfscript>
request.app = structNew();
Application.dsn = "LoveZoneAfrica";
Application.webRoot =
"#getPageContext().getRequest().getContextPath()#/NewLoveZoneAfrica/";
Application.machineRoot = "/NewLoveZoneAfrica/";
Application.cfcRoot = "NewLoveZoneAfrica.com";
Application.Domain = "NewLoveZoneAfrica.com";
factory=CreateObject("java","coldfusion.server.ServiceFactory");
sqlService = factory.getDataSourceService();
dsn = duplicate(sqlService.datasources[Application.dsn]);
if(dsn.driver eq "MSAccess" or dsn.driver eq "MSAccessJet"
or dsn.driver eq "ODBCSocket")
request.app.ucase = "ucase";
request.app.isAccess = true;
else
request.app.ucase = "ucase";
request.app.isAccess = false;
</cfscript>
<!--- End Setting up request variables here. --->
<cfreturn true>
</cffunction>
<cffunction name="onRequestStart" returntype="boolean"
output="true" >
<cfargument name="requestname" required=true/>
<cfif isDefined("form.j_username") and
isDefined("form.j_password")>
<!--- If either password or Username is empty go to
login--->
<cfif form.j_username is "" or form.j_password is "">
<cfinclude
template="#Application.webRoot#Login/Security/Login.cfm">
<cfabort>
</cfif>
<!--- First Check to see wether there is need to log out
user--->
<cfscript>
// create the Security object
Security =
createObject("component","#Application.cfcRoot#.security");
// store authenticate method of security object as roles
variable.
LogQry=Security.authenticate(form.j_username,form.j_password);
</cfscript>
<cfif LogQry.recordcount> <!--- User has
Successfully logged in #GetValidUser# --->
<cfloginuser name="#form.j_username#"
password="#form.j_password#" roles="#valuelist(LogQry.Role)#">
<!--- Update the LastLogin timestamp. --->
<cfscript>Update_LastLogin=Security.LastLogin(form.j_username);
</cfscript>
<cfset request.User.LoggedIn = "1">
<cfset request.User.Username = form.j_username>
<cfset request.User.LastLogin = LogQry.LastLogin_Date
>
<cfelse>
<!---Destroy request --->
<cflock scope="SESSION" throwontimeout="Yes" timeout="7"
type="EXCLUSIVE">
<cfset clearStruct = StructDelete(request, "User")>
</cflock>
<!---Destroy request --->
<cflock scope="SESSION" throwontimeout="Yes" timeout="7"
type="EXCLUSIVE">
<cfset clearStruct = StructDelete(SESSION, "User")>
</cflock>
</cfif>
<cfif NOT isDefined("request.User.LoggedIn")>
<cfset request.loginMessage ="Your Login Username or
Password is Invalid ">
<cfinclude
template="#Application.webRoot#Login/Security/Login.cfm">
<cfabort>
<cfelse>
<!--- If the login procedure is passed duplicate the
request structure into the Session scope. --->
<cflock scope="SESSION" throwontimeout="Yes"
timeout="107" type="EXCLUSIVE">
<cfset Session.User = Duplicate(request.User)>
</cflock>
<cflock name="lck_currentSessions" throwontimeout="Yes"
timeout="107" type="EXCLUSIVE">
<!---THIS has BE CHANgED : bEGIN- original COPY IS @ THE
FOOT --->
<!--- Copy identifying session information into the
Application scope. --->
<cfif NOT isDefined("Application.sessionData")>
<!--- Increment the number of current sessions. --->
<cfset Application.currentSessions =
Application.currentSessions + 1>
<cfset Application.sessionData = ArrayNew(1)>
<cfset Arraysize = 0>
<cfset Application.sessionData[Arraysize+1] =
form.j_username>
<CFELSE>
<!---check to see wether this "Username" appears in the
Application.sessionData.
If so, ignore. If no then append the name to the array so we
have a unique list of usernames--->
<cfset Arraysize = ArrayLen(Application.sessionData)>
<cfset Application.temp = ArrayNew(1)>
<cfif Arraysize>
<cfloop index = "LoopCount" from = "1" to =
"#Arraysize#">
<cfset #ArrayAppend(Application.temp,
Application.sessionData[LoopCount])#>
</cfloop>
<cfdump var="#Application.sessionData#" >
<cfset Isloggedin =
ListFind(ArrayToList(Application.temp), form.j_username)>
<cfif Isloggedin is 0>
<cfset Application.sessionData[Arraysize+1] =
form.j_username>
<!--- Increment the number of current sessions. --->
<cfset Application.currentSessions =
Application.currentSessions + 1>
</cfif>
<cfelse>
<!--- Increment the number of current sessions since twas
empty. --->
<cfset Application.currentSessions =
Application.currentSessions + 1>
<cfset Application.sessionData[Arraysize+1] =
form.j_username>
</cfif>
</cfif>
</cflock>
</cfif>
<cfelse>
<cfif not ListLast(CGI.SCRIPT_NAME, "/") EQ
"logout.cfm">
<!---Check wether the username appears on the list
Application.currentSessions is 0 --->
<cfif NOT isDefined("Session.User.LoggedIn") >
<cfinclude
template="#Application.webRoot#Login/Security/login.cfm">
<cfabort>
</cfif>
</cfif>
</cfif>
<!--- Check to see if a user is logged in on *every* cfm
page request. --->
<cfif not ListLast(CGI.SCRIPT_NAME, "/") EQ
"logout.cfm">
<cflock scope="SESSION" throwontimeout="Yes" timeout="7"
type="READONLY">
<cfif NOT isDefined("Session.User.LoggedIn")>
<cfinclude
template="#Application.webRoot#Login/Security/login.cfm">
<cfabort>
</cfif>
</cflock>
</cfif>
<cfreturn true>
</cffunction>
<cffunction name="onSessionEnd" returntype="void">
<cfargument name="SessionScope" required="true">
<cfargument name="ApplicationScope" required="true">
<cfset request.loginMessage="Nimeingia onSessionEnd">
<cflock name="lck_currentSessions" throwontimeout="Yes"
timeout="7" type="EXCLUSIVE">
<cfset sessionPosition =
ListFind(ArrayToList(arguments.ApplicationScope.sessionData),
arguments.SessionScope.sessionid)>
<cfif sessionPosition neq 0>
<cfset
ArrayDeleteAt(arguments.ApplicationScope.sessionData,
sessionPosition)>
<cfset arguments.ApplicationScope.currentSessions =
arguments.ApplicationScope.currentSessions - 1>
</cfif>
</cflock>
</cffunction>
<cffunction name="onSessionStart" returntype="void">
<cfset request.loginMessage="Nimeingia onSessionEnd">
</cffunction>
<cffunction name="onRequestEnd" returntype="void">
<!--- Write any code that needs to run when the page
request ends. This replaces onRequestEnd.cfm --->
</cffunction>
</cfcomponent>Answered my own quests
http://www.rewindlife.com/archives/000046.cfm -
How to get and set a session variable from backing bean?
Hi im using Jdev 11.1.1.2.0 and i need to set and get a session variable from backing Bean.
Any idea?the class :
package arq.resources;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;
public class SesionSigef {
public FacesContext context;
public HttpSession session;
public SesionSigef() {
super();
context = FacesContext.getCurrentInstance();
session = (HttpSession)(context.getExternalContext().getSession(true));
public Object getVariableSesion(String atributo){
return session.getAttribute(atributo);
public void setVariableSesion(String atributo,Object valor){
session.setAttribute(atributo, valor);
the example of use :
SesionSigef se = new SesionSigef();
DatosRec da = new DatosRec();
da.setDocumentoCip("Aprobar");
se.setVariableSesion("DatosRec", da);
thanks
Joaquin -
Update Session Variable; Username changed
Hello...
My session variable for my website is MM_Username.
After logging into my website, the user can change his/her
username if desired.
I can successfully create the update record form, and after
the user changes the username, the "myinfo" page is shown.
Of course, the session variable is no longer linked to this
user so no information is shown.
Upon changing the username, how can I get my session
variable, "MM_Username" to be attached to this new changed
username?
Thanks!!!!!$_SESSION['MM_Username'] = newusername; // (in PHP)
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"chris.cavage" <[email protected]> wrote in
message
news:gimuiu$2vf$[email protected]..
> Hello...
>
> My session variable for my website is MM_Username.
>
> After logging into my website, the user can change
his/her username if
> desired.
>
> I can successfully create the update record form, and
after the user
> changes
> the username, the "myinfo" page is shown.
>
> Of course, the session variable is no longer linked to
this user so no
> information is shown.
>
> Upon changing the username, how can I get my session
variable,
> "MM_Username"
> to be attached to this new changed username?
>
> Thanks!!!!!
> -
Session variable getting reset when leaving dashboard
I have created a session variable with the 'Enable any user to set the value' option. I'm using the session variable as the default for a dashboard prompt. I'm able to set the variable with that dasboard prompt, and I can confirm that it is indeed getting set properly. So the interaction of the variable and the prompt seems to be in order.
After I make a selection from the dashboard prompt, as long as I stay in the dashboard, the session variable stays set to my selection. I can move from page to page and everything is fine. The selection stays put as I have set it. However, the moment I leave the dashboard, the session variable is reinitialized back to its default value as specified by the SQL in its initialization block. I can go from dashboard to catalog and back to dashboard - boom, it's back to the default. My selection has been replaced. ???
And here's an odd thing: I can look in the query log and see the initialization block code getting run when I log in. So far, so good. I can run the dashboard, make a prompt selection, and see the query log updated just fine. Still OK. BUT... when I switch from dashboard to catalog and back to dashboard, the value of the session variable is reset (I see the default month in my analysis and as the prompt default upon redisplay of the dashboard page), but there's no indication in the query log that the initialization block SQL ran again. The last SQL in the query log still shows my "selected" value in the SQL. The dashboard page is showing the "default", while the last entry in the query log shows the "selected".
Can anyone else confirm this odd behavior? And is there a reason that a session variable should not retain its value throughout the session? I've always viewed session variables as little buckets of single-cell data whose contents are consistent and static for the duration of a session, unless manually changed by a dashboard prompt. If the behavior that I'm seeing is both replicatable and expected, it would appear that my understanding is flawed.
Running 11.1.1.7.0 on Windows Server 2008. Same behavior is occurring in both Firefox 21 and IE 9.Thank you for your answer MK,
I try to write a SQL in my prompt but not work for me:
-In default selection I choose SQL Results and I type: Year(Current_date) and save my prompt and I don't see any value in my dashboardpage, if I click in prompt I can see all members of my year dimension but by default is empty.
I modify the other solution: I have 1hour refresh time and I change for 1 minute, but doesn't work.
the default initializer is in RPD (variable year that belongs to BI_Year Block) and I have written 2009. -
Function to get session variable is not working
I created a report based on the following sql query:
SELECT EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO FROM SCOTT.EMP
WHERE DEPTNO = empcust.current_deptno
empcust.current_deptno is a function which returns the value of the session variable. However, nothing gets returned. The value of the session variable is not found.
I know that the session variable is being set b/c i have a procedure that sets it and prints out the assigned.
This is my code for the current_deptno function. If anyone can help, i'd greatly appreciate it!
procedure current_deptno
return VARCHAR2
as
v_Session portal.wwsto_api_session;
v_Return VARCHAR2(20); --DEPT.DEPTNO%TYPE;
begin
v_Session := portal.wwsto_api_session.load_session('PORTAL','SESS_EMP');
v_Return := v_Session.get_attribute_as_varchar2('DEPTNO');
htp.p('Return session var'||v_Return);
RETURN(v_Return);
end;Hi Imtiaz,
Could you verify that the variable has indeed a value? You could check via the Session Manager in the Admin Tool. You could also check the Query Log to verify whether the Initialization Block is working like expected.
Thanks.
Daan Bakboord
http://obibb.wordpress.com -
How to get session variable value in conditional formatting
I am trying to format my column according to value of a session variable. Normally when comparing to a static value I select value from add button and write the value. What I want is to be able to do this using a session variable. I select variable presentation and as the variable expression I tried MYDAY, NQ_SESSION.MYDAY, VALUEOF(NQ_SESSION.MYDAY), VALUEOF(MYDAY) but nothing works. By the way it is a date value, I don't know it makes any difference
Any help would be appriciatedI am surprised that it is not possible to select a session variable when you want to use conditional formatting. Apparently you can only base conditional formatting on presentation variable or values within a column.
As a workaround you can create an extra column in your request and use a CASE WHEN statement, where you compare the value of the date with the session variable. Then you can base your conditional formatting on that column.
Regards,
Stijn
Message was edited by:
Stijn Gabriels -
Hello to all.
I am developing a shopping cart application in which I use to store some session variables in session object.
The problem arise when I integrate paypal with my application.
I use following code to redirect to the paypal's site
baseURL="https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token="+ack+"&ITEM_NAME="+itmName+"&ITEM_NUMBER="+itnSrNo+"&ITEM_AMT="+paymentAmount;
response.sendRedirect(baseURL);When I return from the paypal's site my all session variables are nulled.
I read somewhere that "response.sendRedirect()" method kills the session.
So, please somebody suggest me the alternatives of this method so that I cannot lose my session.
Thank Youtypurohit wrote:
rajskhr wrote:
I read somewhere that "response.sendRedirect()" method kills the session.
It is not true. response.sendRedirect() don't kills session at all.
rajskhr wrote:
When I return from the paypal's site my all session variables are nulled.When you go to PayPal and return to your actual webapp, It might take longer then your session-timeout configuration in web.xml.
Side effect of this is when you come back to your webapp, session which you left behind before moving to PayPal got expired and you are dealing with new session now.
Increasing session timeout configuration in web.xml might help you. You can also cross check session status by method session.isNew() when you return from PayPal.+Thanks a lot.
You are write my session might expires after returning from the paypals site and I used setMaxInactiveInterval and its working
Thanks again. -
Session variable causing ADODB.Field error '800a0bcd'
i have a page that before the session variable was added,
would display the
text i required if the recordset was empty.
Now i have a session variable on the same page and if the
recordset is
empty, instead of showing the text i need displayed, i get
the following
error:
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been
deleted. Requested
operation requires a current record.
/Help_Desk/verified.asp, line 31
If i remove the session variable code from the page, it works
fine.....why
the conflicts?
<%Session("last")
=(rsVerify.Fields.Item("c_last_name").Value)%>
<%Session("first")
=(rsVerify.Fields.Item("c_first_name").Value)%>
<html>
What im doing is verifying if a user exists in the database.
If they do
there name is stored in a session and used later on the
following pages. If
they do not exist, they are suppose to receive a message
indicating to call
our support center to update there name...
I dont understand why the addition of the above two lines
cause this errorHere is all the code on the page... please let me know if
there is something
incorrect.....
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/USD.asp" -->
<%
Dim rsVerify__varLname
rsVerify__varLname = "%"
If (Request.Querystring("last") <> "") Then
rsVerify__varLname = Request.Querystring("last")
End If
%>
<%
Dim rsVerify__varFname
rsVerify__varFname = "%"
If (Request.Querystring("first") <> "") Then
rsVerify__varFname = Request.Querystring("first")
End If
%>
<%
Dim rsVerify
Dim rsVerify_numRows
Set rsVerify = Server.CreateObject("ADODB.Recordset")
rsVerify.ActiveConnection = MM_USD_STRING
rsVerify.Source = "SELECT c_last_name, c_first_name,
c_middle_name,
c_email_addr FROM AHD.ctct WHERE c_last_name = '" +
Replace(rsVerify__varLname, "'", "''") + "' and c_first_name
= '" +
Replace(rsVerify__varFname, "'", "''") + "' and del = '0'"
rsVerify.CursorType = 0
rsVerify.CursorLocation = 2
rsVerify.LockType = 1
rsVerify.Open()
rsVerify_numRows = 0
%>
<%Session("last")
=(rsVerify.Fields.Item("c_last_name").Value)%>
<%Session("first")
=(rsVerify.Fields.Item("c_first_name").Value)%>
<html>
<head>
<title>Account Verification</title>
</head>
<body text="#000000" link="#0000FF" vlink="#0000FF"
alink="#0000FF"
leftmargin="0" topmargin="0">
<!--#include virtual="/inc/header.asp" -->
<br>
<br>
<% If Not rsVerify.EOF Or Not rsVerify.BOF Then %>
<table width="605" align="center">
<tr bgcolor="#9999FF">
<td><strong>USD Name:</strong></td>
<td><strong><%=(rsVerify.Fields.Item("c_last_name").Value)%>,
<%=(rsVerify.Fields.Item("c_first_name").Value)%></strong></td>
</tr>
<tr>
<td><strong>First
Name:</strong></td>
<td><strong><font
color="#FF0000"><%=(rsVerify.Fields.Item("c_first_name").Value)%></font></strong></td>
</tr>
<tr>
<td><strong>Last Name:</strong></td>
<td><strong><font
color="#FF0000"><%=(rsVerify.Fields.Item("c_last_name").Value)%></font></strong></td>
</tr>
<tr>
<td><strong>Email:</strong></td>
<td><strong><font
color="#FF0000"><%=(rsVerify.Fields.Item("c_email_addr").Value)%></font></strong></td>
</tr>
<tr>
<td><strong>Location:</strong></td>
<td><strong><font
color="#FF0000"><%=(rsVerify.Fields.Item("c_middle_name").Value)%></font></strong></td>
</tr>
<tr>
<td colspan="2"><div
align="center"><strong>If all 4 fields above
contain
your correct information please select from the links
below.<br>
If your are missing any information above please contact the
help
desk
before proceeding.</strong> </div></td>
</tr>
<tr>
<td colspan="2"><hr size="1"> <table
width="400" align="center">
<tr>
<td><div align="center"><strong><a
href="/Help_Desk/usd_stores1.asp">Open
Store / DC
Request</a></strong></div></td>
<td><div align="center"><strong><a
href="/Help_Desk/usd_corp1.asp">Open
Corporate
Request</a></strong></div></td>
</tr>
</table></td>
</tr>
</table>
<% End If ' end Not rsVerify.EOF Or NOT rsVerify.BOF %>
<br>
<div align="center">
<% If rsVerify.EOF And rsVerify.BOF Then %>
<table width="605">
<tr>
<td><div align="center"><font
color="#FF0000"><strong>If you are
receiving
this message, chances are you are not completely setup in
USD.<br>
Please contact the help desk to have your information
verified and
setup
if needed.</strong></font>
</div></td>
</tr>
</table>
<% End If ' end rsVerify.EOF And rsVerify.BOF %>
</div>
<div align="center"></div>
<!--#include virtual="/inc/footer.asp" -->
</body>
</html>
<%
rsVerify.Close()
Set rsVerify = Nothing
%>
"Daniel" <[email protected]> wrote in message
news:[email protected]...
>i have a page that before the session variable was added,
would display the
>text i required if the recordset was empty.
>
> Now i have a session variable on the same page and if
the recordset is
> empty, instead of showing the text i need displayed, i
get the following
> error:
>
> --------------------------
> ADODB.Field error '800a0bcd'
> Either BOF or EOF is True, or the current record has
been deleted.
> Requested operation requires a current record.
>
> /Help_Desk/verified.asp, line 31
> -----------------------------
>
> If i remove the session variable code from the page, it
works fine.....why
> the conflicts?
>
> <%Session("last")
=(rsVerify.Fields.Item("c_last_name").Value)%>
> <%Session("first")
=(rsVerify.Fields.Item("c_first_name").Value)%>
> <html>
>
> --------------
>
> What im doing is verifying if a user exists in the
database. If they do
> there name is stored in a session and used later on the
following pages.
> If they do not exist, they are suppose to receive a
message indicating to
> call our support center to update there name...
>
> I dont understand why the addition of the above two
lines cause this error
>
> -
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] -
Problem with Session variable initialization block
Hi,
I'm getting strange results when using session variables in my repository files.
I have created session variables as specified in the document which is available at
http://www.oracle.com/technology/obe/obe_bi/bi_ee_1013/bi_admin/biadmin.html
The main problem getting with the system session variable (USER) in the select statement.
My select statement is as follows,
select ':USER',case when upper(':USER') = 'KUMAR' then 'APR-05' end from Dual
The problem is while logging into the BI Answers it is allowing all the invalid users to login who does not exist.
when i remove the quotes and simply use :USER in the select statement it is not allowing the invalid users to login but giving error while displaying the results.
when i remove the user variable from select statement its giving correct results.
Can i know what is causing the problem.
Thanks,
Kumar.Hi DK,
Check out my post Rowlevel Security?? and see if it helps you.
Cheers!
-Joe -
Use of session variable to retrieve user language
Hi,
I'm converting some ASP code to JSP and I'm having a problem concerning session variables, in ASP I had something like this
(first.asp)
<td align="center" width=145px><%=getLabel(1)%>
and in second.asp
dim Label(3,2)
function GetLabel(ndx)
GetLabel = Label(ndx, Session("Language"))
end function
clang_PT = 1 ' Portuguese
clang_EN = 2 ' English
Label(0,clang_PT) = "primeira"
Label(1,clang_PT) = "Segunda"
Label(0,clang_PT) = "first"
Label(1,clang_PT) = "second"
when trying to do the same thing in JSP
(first.jsp)
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@include file="labels.jsp"%>
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<%if (session.isNew()) {
session.setAttribute("Language","1");
}%>
<%= getLabel(1)%>
(labels.jsp)
<%@ page language="java" import="java.util.*"%>
<%@page pageEncoding="UTF-8"%>
<%! String getlabel(int ndx){
return label[ndx][session.getAttribute("Language")];
String[][] label = new String[2][2];
%>
<%
int clang_PT = 0; // Portugu�s
int clang_EN = 1; // Ingl�s
label[0][clang_PT] = "primeira";
label[1][clang_PT] = "segunda";
label[0][clang_EN] = "first";
label[1][clang_EN] = "second";
%>
I get
cannot find symbol symbol : variable session location: class org.apache.jsp.experiencia_jsp return label[ndx][session.getAttribute("Language")];
^
and
cannot find symbol : method getLabel(int)
location: class org.apache.jsp.experiencia_jsp
out.print( getLabel(1));
Should I use a bean to store this kind of info?
thanks, Vright...
actually, cuz doing this:
<%!
String getlabel(int ndx){
int lang = Integer.parseInt((String)session.getAttribute("Language"));
return label[ndx][lang];
%>
there's no session object... that creates a method in the class separate from the main JSP method. So you need to either pass the session object in, or just pass the attribute value..
<%!
String getlabel(int ndx, int lang){
return label[ndx][lang];
%>
int lang = Integer.parseInt((String)session.getAttribute("Language"));
String lable = getLabel(ndx, lang); -
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
Maybe you are looking for
-
HT2731 How can I restore my old itunes account on my new computer?
Our old computer crashed and we now have a new one. Am I able to find all of my itunes songs and get them on this computer if I never backed them up?
-
Script to play itunes playlist on start?
I have just done the software upgrade to SL and now my old script doesnt work to auto play an itunes playlist on startup. I found the following script as a replacement but it doesnt seem to run automatically on start up. tell application "iTunes" a
-
Bullets showing up as hearts in LXDE and XFCE?
I'm running into a super strange issue that I haven't been able to find any information on. Basically, when I'm in LXDE or XFCE, whenever I go to a website or any place where I put in a password and it shows up corresponding bullets in lieu of the pa
-
Hi I need some help to save couple of time managing profile settings for every user in our Agency. We use 10.6 Server, 10.6 on the clients and the Adobe Design Standard CS5. To use Adobes CS5 in a good way, many settings need to be stored in the user
-
Avoiding attributes when using transform class
Hi, One more help pls!!!!! When I use transform class and create an XML file, it creates with attributes for the nodes. For exapmle, <MessageOwner type="type" name="name"> How do I avoid this type and name attributes????? Thanx and Regards, Gayathri.