Null session variable
Ok, i have a problem which is really annoying me and i have been stuck on for a while. I am developing a website for my brothers company and am really stuck for time for the launch date. I developed a website last year which worked fine and i am re using the code from that. I am setting a session variable "sessEmail" when the user logs in and want to retrieve it when they go to add a produt to their cart. Here is my code
String Email = request.getParameter("txtEmail");
String Password = request.getParameter("txtPassword");
session.setAttribute("sessEmail",Email);
Object o = session.getAttribute("sessEmail");
String s = o.toString();
out.print(s);
I am just printing out the "sessEmail" to make sure it is working. It works fine when i try and retrieve the session variable on the same page were i set it but on a seperate page it wont work. It is returning a null pointer exception because the session variable has no value. It is occuring when i try to convert an object to a string.
Any help would be much appreciated as i am stuck for time.
Cheers
Ok the first question to be asked is why it is null?
The most obvious answer is that you have cookies disabled, and are not using URL rewriting.
To retain the session, the server issues a "Session Cookie" with your jsessionid in it. If you have cookies switched off on your browser, it won't retain the session.
To confirm this print out session.getId() on your pages. If it continually changes, you aren't keeping your session. If it remains the same, you HAVE got a session, and need to check why you are putting a null value there.
To retain session, you need to run every link/url that gets printed to your page through the method response.encodeURL() which will add on the session id manually if cookies are not supported.
Hope this helps,
evnafets
Similar Messages
-
In my application, when a user logs in, I add some user info to the session which I access on subsequent pages. Its working fine.
But, when I run my application inside a portlet in the Oracle portal and read the values of session variables, they turn out to be null.
What could be the problem?Not sure what the portlet thing for Oracle portal is, but the first thing I'd check is that the browser is getting the session ID cookie from the server. It's the most likely problem, since if the session ID is not sent to the browser, subsequent requests can't send it back, thus the server can't get the same session back. If you can't figure out how to get the cookie to come thru (assuming that's the problem), you'd have to use URL rewriting (response.encodeURL()) to encode all URLs for all links and forms to get the session ID added to the link.
-
To obtain the value of a session variable in a JAVA class
Hello again.
I have a JSP page, in witch I kept a session variable with a value, and later (in the same JSP page) I use a JAVA class to obtain the value stored in this session variable (I make this to verify that this works well and that this is possible)
When I run the file, I obtain the following error:
excepci�n
org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
causa ra�z
java.lang.NullPointerException
ConfigAnlsEspect.Config.<init>(Config.java:18)
org.apache.jsp.admin.PaleoPlot.configAnEsp_jsp._jspService(configAnEsp_jsp.java:103)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)And my code is:
------------->The JSP file:<-----------------
session.setAttribute("VarSession", "empty");
<%@ page import="ConfigAnlsEspect.Config"%>
<%
Config ObjConfigAE = new Config();
String valorDev = ObjConfigAE.getValueSession();
out.println("<br>Returned= -->"+valorDev+"<--<br>");
%>
------------->The JAVA class:<-----------------
package ConfigAnlsEspect;
import java.io.*;
import java.net.*;
import java.util.*;
import java.text.*;
import javax.servlet.http.HttpSession;
import javax.servlet.*;
import javax.servlet.http.*;
public class Config extends HttpServlet{
HttpSession session = null;
String valor = null;
public Config (){
valor = (String)session.getAttribute("VarSession");
public String getValueSession(){
return valor;
}Why I obtain java.lang.NullPointerException ??
Thanks very muchI have solved the problem, doing (in the java class):
package ConfigAnlsEspect;
import java.io.*;
import java.net.*;
import java.util.*;
import java.text.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.*;
import javax.servlet.http.*;
public class Config extends HttpServlet{
HttpSession session;
String valor = null;
public Config (HttpSession session){
this.session = session;
valor = (String)this.session.getAttribute("VarSession");
public String getValueSession(){
return valor;
}is it rigth ?? -
Help Needed in checking session variable
In a sample site, I am calling a bounded task flow from an unbounded task flow. In the called taskflow the default activity is a router which checks the session variable, and the home page will be loaded only if the session variable is not null. If session variable is null router will lead to a page dispalying 'session expired'. But even after clearing the session if I copy pasted the previous url, the home page is loading. But when I call bounded taskflow from a bounded taskflow, it is working fine. Can anyone suggest any solution? Thanks in advance
Thanks for the reply. I'm using jdev 11.1.1.5.0.. I'm just trying with a sample example. I have a login page and when the user logins, the user name is stored in session. the loginpage view activity is in adfc config unbounded taskflow. The login credentials is validated in a backing bean and based on the return value, if the login is valid, a bounded taskflow 'hometaskflow' is called. In this bounded taskflow, the default activity is a router wchich checks the username stored in session. If the username is not null it will lead to the 'homepage' view. Else if it is null it will lead to a 'sessionexpired' view.
In the java class of login page I'm accessing the session variable as shown
public Username getSessionBean()
Username username =
(Username)resolveExpression("#{Username}");
return username;
public static Object resolveExpression(String expression)
FacesContext facesContext = FacesContext.getCurrentInstance();
Application app = facesContext.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = facesContext.getELContext();
ValueExpression valueExp =
elFactory.createValueExpression(elContext, expression,
Object.class);
return valueExp.getValue(elContext);
On login button click the function being executed is as shown
public String onLoginClick() {
if(String.valueOf(itUserName.getValue()).equals("admin")
&& String.valueOf(itPassword.getValue()).equals("admin"))
Username username=getSessionBean();
username.setUsername(itUserName.getValue().toString());
return "success";
else {
return "invalid";
And to set username as null on logout, I used this function on logout click
public void clearSession()
Username username=getSessionBean();
username.setUsername(null);
The EL expression used to check the value of session variable is
#{sessionScope.Username.username==null} outcome is expired
#{sessionScope.Username.username!=null} outcome is active
This worked when I used in a bounded taskflow, which is being called from another bounded taskflow. But not working in this scenario... -
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 -
Code to set and destroy session variables in Java Server Pages(JSP)
code to set and destroy session variables in Java Server Pages(JSP)
we have use following statement to set session variable
session.setAttribute("userClient",id);
we have use following statement to destroy session variable
session.setAttribute("userClient","");
and
the session.invalidate() is not working
Plz. solve this probemcode to set and destroy session variables in Java
Server Pages(JSP)
we have use following statement to set session
variable
session.setAttribute("userClient",id);
we have use following statement to destroy session
variable
session.setAttribute("userClient","");Perhaps if you tried using
session.setAttribute("userClient", null);
or
session.removeAttribute("userClient");
and
the session.invalidate() is not workingNot working how?
>
Plz. solve this probem -
How to pass a session variable to the bussines layer?
Hello,
I am doing a management application, and I need to store the login user that make insertions on any table, and the pages does not has backing beans.
I had try to do that bindding the value field of a hidden attribute with the session variable, but it only change the value of the one. My second attempt was make an javascript function to do that on the page´s load, but it not looks like a good solution.
Someone knows a way to sent the session value to the bussines layer? O a way to access from the Bussines layer to the session?
Thanks
Tony<p>
Hi,
</p>
<p>
Another solution (that I always use) is storing simultaneously the same data in HttpSession (in view layer) and session hashtable (in businness layer).
</p>
<p>
You can put and get these data in any businness component using following methods:
</p>
<p>
<font face="courier new,courier" size="2" color="#0000ff">
private void setToJboSession(String key, Object val){</font>
<font face="courier new,courier" size="2" color="#0000ff"> Hashtable userData = getDBTransaction().getSession().getUserData();
if (userData == null) {
userData = new Hashtable();
userData.put(key, val);
}</font>
</p>
<p>
and
</p>
<p>
<font face="courier new,courier" size="2" color="#0000ff">
private Object getFromJboSession(String key){
return getDBTransaction().getSession().getUserData().get(key);
}</font>
</p>
<p>
Kuba
</p> -
How to Create a Session variable in JSP?
How to create a session variable and add attributes to it?
For example i want to create a session variable called "name" and add value "user" to it? if i try to do it with setAttribute(), it is giving error as both is of type string? how to do it? kindly help meThis is variable what is working in my aplication
String variable;
if(user == null){
user=new String("");
}//if you don'y do this you will have null pointer exception
session.setAttribute("user",user);//put value
String name=(String)session.getAttribu("user"); //get value;
I hope this will help -
Filter recordset with session variable
This has never happened to me before, but for some reason, my
recordset that drives a dynamic table won't filter results based on
a session variable. I know session variables are working because I
have the session variable echo on the page (dragged-n-dropped my
session variable from the Bindings panel to my page), and that
works fine. So why can't I filter my recordset with the same
session variable??? What's going on?
PS: I've attached my result page's code to this
message.Gabe the Animator wrote:
> <?php require_once('Connections/sales.php'); ?>
> <?php
> if (!function_exists("GetSQLValueString")) {
> function GetSQLValueString($theValue, $theType,
$theDefinedValue = "",
> $theNotDefinedValue = "")
> {
> $theValue = get_magic_quotes_gpc() ?
stripslashes($theValue) : $theValue;
>
> $theValue = function_exists("mysql_real_escape_string")
> mysql_real_escape_string($theValue) :
mysql_escape_string($theValue);
>
> switch ($theType) {
> case "text":
> $theValue = ($theValue != "") ? "'" . $theValue . "'" :
"NULL";
> break;
> case "long":
> case "int":
> $theValue = ($theValue != "") ? intval($theValue) :
"NULL";
> break;
> case "double":
> $theValue = ($theValue != "") ? "'" .
doubleval($theValue) . "'" :
> "NULL";
> break;
> case "date":
> $theValue = ($theValue != "") ? "'" . $theValue . "'" :
"NULL";
> break;
> case "defined":
> $theValue = ($theValue != "") ? $theDefinedValue :
$theNotDefinedValue;
> break;
> }
> return $theValue;
> }
> }
>
> $colname_rsSales = "-1";
> if (isset($_SESSION['state'])) {
> $colname_rsSales = $_SESSION['state'];
> }
> mysql_select_db($database_sales, $sales);
> $query_rsSales = sprintf("SELECT * FROM sales WHERE city
= %s",
> GetSQLValueString($colname_rsSales, "text"));
> $rsSales = mysql_query($query_rsSales, $sales) or
die(mysql_error());
> $row_rsSales = mysql_fetch_assoc($rsSales);
> $totalRows_rsSales = mysql_num_rows($rsSales);
>
> session_start(); ?>
The issue is that PHP doesn't "work" with session values
until the session has started, and that must be done on each page,
and must be done in the code *above* any reference to a session
variable. The code you posted has the session_start() after it
tries to use the session value ito filter the recordset. So move
this last line of code ( session_start(); ) above $colnam_rsSales =
"-1". Better yet, use:
if(!session_id()){
session_start();
To prevent some versions of PHP from generating a
warning/notice if you've called session_start() on the page already
and you call it again.
Danilo Celic
| Extending Knowledge Daily :
http://CommunityMX.com/
| Adobe Community Expert -
Session variable not passing between pages
Hi, I've got a form that calculates checkbox values and puts them in a total field called txtTotal. When the user clicks send, I need to pass the total to a payment page. The form page has PHP
session_start();
$_SESSION['sessTotal'] = $_POST['txtTotal'];
and the payment page has
session_start(); at the top of the page and <?php echo $_SESSION['sessTotal']; ?> where I want the total to display. The total does not carry over to the payment page and I can't work out why.
Here is all the PHP from the form page as I'm pretty new to PHP and not sure if there's a conflict (should session_start appear more than once?) Thanks guys
<?php require_once('Connections/df.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
$_SESSION['sessTotal'] = $_POST['txtTotal'];
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "index.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
?>
<?php
if (!isset($_SESSION)) {
session_start();
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
if (($strUsers == "") && true) {
$isValid = true;
return $isValid;
$MM_restrictGoTo = "index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
return $theValue;
$colname_userDets = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_userDets = $_SESSION['MM_Username'];
mysql_select_db($database_df, $df);
$query_userDets = sprintf("SELECT usersId, userName, password, name FROM users WHERE userName = %s", GetSQLValueString($colname_userDets, "text"));
$userDets = mysql_query($query_userDets, $df) or die(mysql_error());
$row_userDets = mysql_fetch_assoc($userDets);
$totalRows_userDets = mysql_num_rows($userDets);
?>OK I got it. I needed
session_start();
$_SESSION['sessTotal'] = $_POST['txtTotal'];
on the payments page as well, not just session_start(); -
How do I prepopulate a bind variable from a session variable?
Hello. I have a scenario where I have a customer Id I need to set as the bind variable and then execute the query before the page comes up. How do I do this? Here's what I've tried (and why it didn't work)
- I tried using the 'ExecuteWithParameters' method from the view object as a method in the task flow. I would then pass in the session variable as a parameter. For some reason it can never find the executewithparameters method on the view object. I'm guessing because it wants to go through the application module
Next ...
- I created a client method in the AM call setCust Id with the following code:
public void setUserNameBind(String userName)
System.out.println("Set param:" + userName);
getFndUserVVO1().setNamedWhereClauseParam("UserNameBind", userName);
getFndUserVVO1().executeQuery();
This worked. However when I ran the debug it instantiates the VO again but with a NULL for the bind parameter. So on the screen it always has the NULL VO.
Finally ...
- I tried to put the method in the binding for the page as a method call. However, the method never got called before the page came up.
This seems like a pretty simple problem. Any ideas?
Thanks!Hi,
1 - create a bind variable and add it to the ViewObject query
2 - drag the ExecuteWithParams operation under the ViewObject (DataControl Palette) to the page
3 - this is created as a button. In the source editor (NOT THE VISUAL EDITOR), delete the button so the binding remains
4 - for the bind variable in the ExecutWeithParams, set its value to #{sessionScope.attribute_name}
5 - in the bindings file, under executables, create an "invokeAction" entry and point it to the executeWithParams operation
Frank -
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); -
Problem accessing session variables in JSP
Hi all,
i am retrieving the value of session variables in a JSP page. the session varibale
is set at the
server side. sometimes the jsp is able to retrieve the value and sometimes it
doesn't.
Thanks & Regards
Tarun
if getAttribute return null so there is no such session attribute,anyway
check your browser if cookies are enabled.
"Tarun Mangal" <[email protected]> wrote in message
news:400759e9$[email protected]..
>
> Hi all,
> i am retrieving the value of session variables in a JSP page. the session
varibale
> is set at the
> server side. sometimes the jsp is able to retrieve the value and sometimes
it
> doesn't.
>
> Thanks & Regards
> Tarun
-
Need Help With Redirect That Uses Session Variable
I am new to dynamic sites, php, and developer toolbox, but I have been able to create a login site using the different form wizards fairly easily (in CS3 with Developers toolbox).
<br />
<br />I am trying to set a server behavior on a page that redirects the user to a new page if a session variable matches a recordset.
<br />
<br />I was using an extension (PHP Sessions - http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=681308 ) that worked great, but when I installed developers toolbox, it stopped working (get error message about runtime/MX environment).
<br />
<br />Ive been struggling for days and this is what Ive come up with so far:
<br />------------------------------------
<br />session_start();
<br />if (!isset($HTTP_SESSION_VARS[$_SESSION['kt_firstname']]) || $HTTP_SESSION_VARS[$_SESSION['kt_firstname']] = $row_Recordsetfname['firstname']) {
<br /> header ("Location: ../firstname/firstname1.php");
<br />}
<br />------------------------------------
<br />
<br />It redirects regardless of the match. Any ideas on what I can do to get this working? Here is all of the code (with block from above inserted) up until the doc type:
<br />------------------------------------
<br /><?php require_once('../Connections/project1.php'); ?>
<br /><?php<br />// Load the tNG classes<br />require_once('../includes/tng/tNG.inc.php');<br /><br />// Make unified connection variable<br />$conn_project1 = new KT_connection($project1, $database_project1);<br /><br />//Start Restrict Access To Page<br />$restrict = new tNG_RestrictAccess($conn_project1, "../");<br />//Grand Levels: Any<br />$restrict->Execute();<br />//End Restrict Access To Page<br /><br />if (!function_exists("GetSQLValueString")) {<br />function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") <br />{<br /> $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;<br /><br /> $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);<br /><br /> switch ($theType) {<br /> case "text":<br /> $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br /> break; <br /> case "long":<br /> case "int":<br /> $theValue = ($theValue != "") ? intval($theValue) : "NULL";<br /> break;<br /> case "double":<br /> $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";<br /> break;<br /> case "date":<br /> $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br /> break;<br /> case "defined":<br /> $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;<br /> break;<br /> }<br /> return $theValue;<br />}<br />}<br /><br />// FELIXONE - 2002 SB by Felice Di Stefano - www.felixone.it<br />session_start();<br />if (!isset($HTTP_SESSION_VARS[$_SESSION['kt_firstname']]) || $HTTP_SESSION_VARS[$_SESSION['kt_firstname']] = $row_Recordsetfname['firstname']) {<br /> header ("Location: ../firstname/firstname1.php");<br />}<br /><br />$colname_Recordsetfname = "-1";<br />if (isset($_SESSION['kt_user_name'])) {<br /> $colname_Recordsetfname = $_SESSION['kt_user_name'];<br />}<br />mysql_select_db($database_project1, $project1);<br />$query_Recordsetfname = sprintf("SELECT firstname FROM registration WHERE user_name = %s", GetSQLValueString($colname_Recordsetfname, "text"));<br />$Recordsetfname = mysql_query($query_Recordsetfname, $project1) or die(mysql_error());<br />$row_Recordsetfname = mysql_fetch_assoc($Recordsetfname);<br />$totalRows_Recordsetfname = mysql_num_rows($Recordsetfname);<br /><br />$colname_Recordset1 = "-1";<br />if (isset($_SESSION['kt_user_name'])) {<br /> $colname_Recordset1 = $_SESSION['kt_user_name'];<br />}<br />mysql_select_db($database_project1, $project1);<br />$query_Recordset1 = sprintf("SELECT `Date` FROM registration WHERE user_name = %s", GetSQLValueString($colname_Recordset1, "text"));<br />$Recordset1 = mysql_query($query_Recordset1, $project1) or die(mysql_error());<br />$row_Recordset1 = mysql_fetch_assoc($Recordset1);<br />$totalRows_Recordset1 = mysql_num_rows($Recordset1);<br />?>
<br />
<br />------------------------------I am new to adobe toolbox... I ve created a ligin page but not sure how to pass the session variable. I am trying to direct successful login to a page like... index.php?id=filter
<br />
<br />been struggling all day with this. Please help!!!
<br />
<br /><?php require_once('Connections/comm.php'); ?>
<br /><?php<br />// Load the common classes<br />require_once('includes/common/KT_common.php');<br /><br />// Load the tNG classes<br />require_once('includes/tng/tNG.inc.php');<br /><br />// Make a transaction dispatcher instance<br />$tNGs = new tNG_dispatcher("");<br /><br />// Make unified connection variable<br />$conn_comm = new KT_connection($comm, $database_comm);<br /><br />// Start trigger<br />$formValidation = new tNG_FormValidation();<br />$formValidation->addField("kt_login_user", true, "text", "", "", "", "");<br />$formValidation->addField("kt_login_password", true, "text", "", "", "", "");<br />$tNGs->prepareValidation($formValidation);<br />// End trigger<br /><br />// Make a login transaction instance<br />$loginTransaction = new tNG_login($conn_comm);<br />$tNGs->addTransaction($loginTransaction);<br />// Register triggers<br />$loginTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "kt_login1");<br />$loginTransaction->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);<br />$loginTransaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "{kt_login_redirect}");<br />// Add columns<br />$loginTransaction->addColumn("kt_login_user", "STRING_TYPE", "POST", "kt_login_user");<br />$loginTransaction->addColumn("kt_login_password", "STRING_TYPE", "POST", "kt_login_password");<br />$loginTransaction->addColumn("kt_login_rememberme", "CHECKBOX_1_0_TYPE", "POST", "kt_login_rememberme", "0");<br />// End of login transaction instance<br /><br />// Execute all the registered transactions<br />$tNGs->executeTransactions();<br /><br />// Get the transaction recordset<br />$rscustom = $tNGs->getRecordset("custom");<br />$row_rscustom = mysql_fetch_assoc($rscustom);<br />$totalRows_rscustom = mysql_num_rows($rscustom);<br /><br />?>
<br />
<br />
<br />
<br />
<br />
<br />
<script src="includes/common/js/base.js" type="text/javascript"></script>
<br />
<script src="includes/common/js/utility.js" type="text/javascript"></script>
<br />
<script src="includes/skins/style.js" type="text/javascript"></script>
<br /><?php echo $tNGs->displayValidationRules();?>
<br />
<br />
<br />
<br /><?php<br /> echo $tNGs->getLoginMsg();<br />?>
<br /><?php<br /> echo $tNGs->getErrorMsg();<br />?>
<br />
<form method="post" id="form1" class="KT_tngformerror" action="%3C?php%20echo%20KT_escapeAttribute(KT_getFullUri());%20?%3E">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<table cellpadding="2" cellspacing="0" class="KT_tngtable">
<tr>
<td class="KT_th">
<label for="kt_login_user">Username:</label>
</td>
<td>
<input type="text" name="kt_login_user" id="kt_login_user" value="<?php echo KT_escapeAttribute($row_rscustom['kt_login_user']); ?>" size="32" />
<br /> <?php echo $tNGs->displayFieldHint("kt_login_user");?> <?php echo $tNGs->displayFieldError("custom", "kt_login_user"); ?></td>
</tr>
<tr>
<td class="KT_th">
<label for="kt_login_password">Password:</label>
</td>
<td>
<input type="password" name="kt_login_password" id="kt_login_password" value="" size="32" />
<br /> <?php echo $tNGs->displayFieldHint("kt_login_password");?> <?php echo $tNGs->displayFieldError("custom", "kt_login_password"); ?></td>
</tr>
<tr>
<td class="KT_th">
<label for="kt_login_rememberme">Remember me:</label>
</td>
<td>
<input <?php if (!(strcmp(KT_escapeAttribute($row_rscustom['kt_login_rememberme']),"1"))) {echo "checked";} ?> type="checkbox" name="kt_login_rememberme" id="kt_login_rememberme" value="1" />
<br /> <?php echo $tNGs->displayFieldError("custom", "kt_login_rememberme"); ?></td>
</tr>
<tr class="KT_buttons">
<td colspan="2">
<input type="submit" name="kt_login1" id="kt_login1" value="Login" />
<br /></td>
</tr>
</table>
<br />
<a href="forgot_password.php">Forgot your password?</a>
<br /></form>
<br />
<p> </p>
<br />
<br /> -
Server hangs and session variable value not maintained.
dear all,
this is exteremetly urgent. i upgraded my tomcat to 4.1.24.but i have problems running the same code which was working earlier, i get null in the value of session variable. and also get the following error
////////////////error got /////////////
Compile failed; see the compiler error output for details.
at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:842)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:682)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:317)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext
.java:473)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:190)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
95)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
rValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:22
3)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:619)
at java.lang.Thread.run(Thread.java:536)
///////////////end of error messsge ////////////
the code where i am getting this message is as follows
<%@ page session="true"%>
<HTML>
<HEAD><TITLE> LOGGED IN ok</TITLE> </HEAD>
<%@ page import="java.sql.*" %>
<%! // declaring variables
String s = "";
java.sql.ResultSet rs=null;
java.sql.Connection con;
java.sql.Statement stmt=null,stmt1=null;
String username = "";
String password = "";
String Ousername = "";
String Opassword = "";
String changepass="";
String usertype ="",useremail="",EmpName="";
%>
<body>
<%
try
//set session for max of 100 milliseconds
// session.setMaxInactiveInterval(10000);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = java.sql.DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};" +"DBQ=c:/vishal/HelpDesk.mdb;DriverID=22;READONLY=false","","");
stmt = con.createStatement();
s = "select * from LoginUser";
username = request.getParameter("LogonId"); //get this through prev. form
password = request.getParameter("txtPassword");
out.println(username + " " + password);
// make explicitly to lower case
username = username.toLowerCase();
rs = stmt.executeQuery(s);
while(rs.next())
//getting data from database
Ousername = rs.getString("EmpName");
Opassword = rs.getString("Password");
useremail = rs.getString("EmailId");
usertype = rs.getString("UserType");
if(Opassword.equals(password) && Ousername.equals(username)) //found match correct entry
changepass = request.getParameter("PasswordNew");
if(changepass != null)
stmt1 = con.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_UPDATABLE);
s = "update LoginUser set Password = '" + changepass + "' where EmpName = '" + username +"'";
out.println(s);
stmt1.executeUpdate(s);
stmt1.close();
if(usertype.equals("User") == false)//ie admin
session.setAttribute("username",username);
************************this value not maintained *********************
session.setAttribute("useremail",useremail);
session.setAttribute("usertype",usertype);
************************this value not maintained *********************
//closing connections
%>
<jsp:forward page= "ComplaintType.jsp" />
<%
else //user
EmpName = username;
session.setAttribute("EmpName",EmpName);
session.setAttribute("useremail",useremail);
//closing connections
%>
<jsp:forward page="ComplaintCategory.jsp" />
<%
}//end if
}//while loop
//first closing connections then forwarding
%>
<jsp:forward page="InvalidLOGIN.jsp" />
<%
///rs.close();
////closing
//stmt.close();
// con.close();
}//try
catch(Exception ep)
out.println(ep);
System.exit(1);
%>
</BODY>
</HTML>hi all,
thanx a lot for your help,specially hari52
hari52 strangely enough the code started working,but
now i have another problem
after a while my server hangs or gets shutdown ,a
message is shown as
"java.exe has generated error and will be shutdown"
i know that more connections can be a prob. but i
make sure that connections r closed on each page,also
i am a newbie and do not have the time at present to
learn abt. connection pool ,can this problem be
solved easily?
it would be a great help again on your part,
thanx again,You remove the System.exit(1) line from the code inside the catch block
and try again. That's the reason tomcat getting down. System.exit(1) should not be used inside jsp. it will make the underlaying Servlet Engine to shutdown.
Maybe you are looking for
-
"Error while trying to sync Audio and Midi"
"Error while trying to sync Audio and Midi" I have been having this problem now and then for some time. Now, I can't run any audio files without a lot of popping. I tried all the suggestions on the support document for this issue. I even downloaded n
-
Can this new service of itunes/match allow you to retrieve songs from an older style ipod, store them in match, and then download them onto a new computer/itunes? The original computer that contained these songs has since been replaced b/c it broke
-
Error the port of the service registry
Dear everyone, please help me, i got the error message as below: Information for this WSDL portType has not been obtained successfully. Some errors have occured. (E.g. some of the parent entities might be corrupted or unpublished.) Error message: WSD
-
Submit PDF form data IMS database.
Hello I have developed a pdf form using livecycle designer and it has a submit button in it. The form is published to our organization website. What we would like to do is, when the user opens and fills up the pdf form either on web browser / or afte
-
Multiple sequences on one table?
I have a simple table with 3 columns: ID, DML_ID and VALUE. The table was designed to be a metadata table with values for certain DML_IDs. The table has been maintained by IT. However, now the users wants to have control over some of the values. Let'