Session variables in jsp,php

Dear friends,
is there any way tht i can pass the session variables set in a jsp file to a php file. Is there any way to do this apart from setting cookies?
plz help!!
bussa

You can create POST or GET request.

Similar Messages

  • How to use session variable in JSP function  & How to use both JSP  Servlet

    Hi,
    I am new to JSP and servlets
    Still I am devloping a website in JSP. I am not mixing JSP with servlets, but I do create Java files for bean, logic and database works.
    I try to keep the hard coding part out of JSP.
    I dont how to use both JSP and Servlets in combination.
    Hence If needed I write some functions in JSP.
    but it gives me error
    +<%! public void abc()+
    +{+
    int intUserId = Integer.valueOf((Integer) session.getAttribute("MySession_UserID"));
    +}+
    +%>+
    Saying cannot find symbol session
    1) So can u please tell how can I access session variables within JSP function
    2) And also give me some links/tutorials about useing both JSP and Servlets in combination.
    Thanks
    Venkat

    The application architecture when you use Servlets and JSP in a standard MVC pattern is explained here (under the heading "Integrating Servlets and JSP Pages") and here ...

  • 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
              

  • 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
    Victor

    Appropriately 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

  • How to retrieve sessions variables in JSP

    hi,
    I am trying to retrieve session variable from servlet to JSP.
    In the servlet i am retrieving employeenames from database and storing them in a ArrayList variable then i am setting this variable into the session.
    When retrieving the session in the jsp it displays as [empname1, empname2].
    Please help how to retrieve them
    Thanks in Advance,
    sha

    At the servlet:
    ArrayList<String> employeeNames = new ArrayList<String>();
    employeenames.add(blahBlahblah);
    session.setAttribute("eNames", employeeNames);
    At the JSP:
    ArrayList<String> names = (ArrayList<String>) session.getAttribute("eNames");
    for (String nom : names) {
    do something with the name stored in String variable nom...
    }

  • Retrieving a session variable from a php script and putting it in an applet

    I have a chat applet and i'm trying to have a session variable in one my php scripts be setted onto the user area of my chat. Would it start out by doing this?
    <object codetype="application/java"
    code = "ClientApplet.class"
    width = "300"
    height = "400"
    classid = "the name of the session variable">
    </object>

    No.
    Use the parameter tags.

  • 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 me

    This 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

  • Passing Session Variable from PHP to Applet

    I'm trying to pass a session variable from a PHP script to a third party applet. The applet needs to accept the variable as a string into a parameter. I think the htnl has to be dynamically created to turn the session variable into a string for the parameter value. Any suggestions ?

    This is really a PHP question. You might get better results on a PHP forum.

  • Servlet/PHP Session Variables

    Hello Everyone,
    I am running an servlet that requires authentication. The authentication is done by a PHP program, while the heavy lifting is done by a servlet. How do I pass a session variable from my php to my servlet so that my servlet knows the user is allowed. I have tried
    Object done = session.getAttribute("loggedIn");
    with "loggedIn" being set by my php file, but done is always null. Any help is greatly appreciated especially if it is cookie free.
    Sincerely,
    Chem E

    You could consider the following solution: on click of the link, fire a specific Ajaxical request from the server where PHP runs to the server where Java runs to obtain an lengthy and unique key which expires within a few seconds, use JS+DOM to add that key as a query parameter to the link value and after opening the link let the Java side determine the key and handle accordingly.
    You only need to write code so that it is hack safe.

  • 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 probem

    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","");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

  • Help with session variable please - CS5.5 PHP

    Hi all,
    I am needing a little assistance with using a session variable and hope that someone may point me in the right direction.
    I have created a PHP page that uses the Dreamweaver 'User Authentication' feature, and the basics of this works fine, directing a user to the correct pages depending on whether they are or are not a valid user. I would like however to personalise the 'valid user' page with the persons Username as entered in the User Authentication table....a seemingly simple task using a session variable, but one that I just don't seem to be able to get working!
    The code generated for the UA on page 1 is as follows:
    <?php
    // *** Validate request to login to this site.
    if (!isset($_SESSION)) {
      session_start();
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($_GET['accesscheck'])) {
      $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    if (isset($_POST['txtfirst_name'])) {
      $loginUsername=$_POST['txtfirst_name'];
      $password=$_POST['txtsurname'];
      $MM_fldUserAuthorization = "";
      $MM_redirectLoginSuccess = "member_update.php";
      $MM_redirectLoginFailed = "login.php";
      $MM_redirecttoReferrer = false;
      mysql_select_db($database_panto, $panto);
      $LoginRS__query=sprintf("SELECT firstname, surname FROM web_access WHERE firstname=%s AND surname=%s",
        GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
      $LoginRS = mysql_query($LoginRS__query, $panto) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
        if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
        //declare two session variables and assign them
       $_SESSION['MM_Username'] = $loginUsername;
        $_SESSION['MM_UserGroup'] = $loginStrGroup;         
        if (isset($_SESSION['PrevUrl']) && false) {
          $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];   
        header("Location: " . $MM_redirectLoginSuccess );
      else {
        header("Location: ". $MM_redirectLoginFailed );
    ?>
    Firstly, the text highlighted in red above appears to be setting the session variable that I require. Is This correct?
    If so, what is the code that I need to place in page 2 to use that session variable? or
    Do I need to do something else on page 1 to properly assign the session variable?
    Would really appreciate your expertise
    Mark

    It looks as though you've set the columns incorrectly in the User Authentication server behavior. This is the SQL query that checks the user's credentials:
      $LoginRS__query=sprintf("SELECT firstname, surname FROM web_access WHERE firstname=%s AND surname=%s",
        GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
    You're looking for firstname and surname, whereas you should be looking for the user's login name and password.
    $_SESSION['MM_Username'] is a session variable that stores the user's login name. To use it in a subsequent page, all that's needed is for the page to begin with session_start(). You can then echo the value to display it.
    If you want to display the person's real name, you need to create a recordset in the second page using $_SESSION['MM_Username'] to find the firstname and surname. Alternatively, you can edit the existing code like this (I've copied only part of it):
      $LoginRS__query=sprintf("SELECT firstname, surname FROM web_access WHERE firstname=%s AND password=%s",
        GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
      $LoginRS = mysql_query($LoginRS__query, $panto) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
        $row = mysql_fetch_assoc($LoginRS);
         $_SESSION['full_name'] = $row['firstname'] . ' ' . $row['surname'];
        if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
        //declare two session variables and assign them
       $_SESSION['MM_Username'] = $loginUsername;
        $_SESSION['MM_UserGroup'] = $loginStrGroup;
    You can then use $_SESSION['full_name'] in a subsequent page that begins with session_start().

  • 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);

  • Struts-JSP : how to use session variable?

    Hi,
    i'm new to both struts and JSP and have a doubt here -
    I'm creating a web application in which a user logs in.
    I need to access this user's userid (id name with which he logs in) in my action classes. how can i do this ?
    please help !
    Thanks in advance,
    susen

    // set session variable
    session.setAttribute("value","hello world");
    // retrieve session variable
    HttpSession session = request.getSession(false);
    String variable = (String) session.getAttribute("value");
    variable will have "hello world"
    Edited by: abel on May 12, 2008 4:52 AM

  • Jsp session variable in javascript

    hi,
    i want use a jsp session variable inside a javascript code, for this i am using the following function,
    function checkList()
    <% String ecode1=(String)session.getAttribute("e_numb"); %>
    var code=<%=ecode1%>
    alert (code)
    this is showing an error can any one please help me,
    thanks
    saurabh

    You have ',%String ecode1' within the javascript. JSP will not recognize 'String' as a java class unless you import the String class. Something like <%@ page import = "java.util.* " %> Incorrect. String is part of java.lang, which is always imported into a java class.
    Most probably what is missing in the javascript is
    - missing quotes ? Not sure if this value is meant to be interpreted as a number or not.
    - missing semicolon
    function checkList()
    <% String ecode1=(String)session.getAttribute("e_numb"); %>
    var code="<%=ecode1%>";
    alert (code);
    }Lets assume that the value of e_numb is "42"
    after running this as a jsp, it should produce the following on the resulting html page. You can see it by viewing the source.
    function checkList()
    var code="42";
    alert (code);
    }Check that to see it has produced valid javascript
    Cheers,
    evnafets

  • SESSION VARIABLE in PHP

    I am new to web applications, but for what I need is to know
    how to use session variables. When a user logins I want thier
    information stored so when they visit my account they are able to
    see thier information and not someone elses. Any help should be in
    PHP format. Thank you in advance.

    prashi123 wrote:
    > I am new to web applications, but for what I need is to
    know how to use session
    > variables. When a user logins I want thier information
    stored so when they
    > visit my account they are able to see thier information
    and not someone elses.
    > Any help should be in PHP format. Thank you in advance.
    http://www.php.net/manual/en/features.sessions.php
    David Powers
    Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    http://foundationphp.com/

Maybe you are looking for

  • Hyperlinks from InDesign to Acrobat

    I am using CS3 programs on a PC on Windows XP I'm trying to create hyperlinks in InDesign. When I export the document to a pdf, I clicked "include interactive elements." However, in Acrobat, it only makes the email addresses or web addresses active.

  • ITunes could not synch calendars to iPhone because the iPhone disconnected

    Started getting an error message during iPhone synch about two weeks ago: "iTunes could not synch calendars to iPhone because the iPhone disconnected" - Am synching to my Outlook calendar on a system running Windows 7 - Everything else (contacts, pod

  • How to refer a particular filed of a Table data type

    DECLARE           CURSOR C1 IS SELECT                                    GLUSR_USR.GLUSR_USR_ID BYER_ID,                                    GLUSR_USR.GLUSR_USR_ADD1 BUYER_ADD           FROM                GLUSR_USR           WHERE                ROWN

  • How Do I Change Default Chapter Numbers When Compressing for iPad?

    Basically, I'd like to export a program from a FCP 7 timeline with included chapter and compression markers and compress it using Compressor 3.5 or 4.  The program is intended for distribution via iPad and I'd like to include medical disclaimers and

  • Using anchors within actions?

    Hi, I'm quite new to Edge Animate CC, I just created a menubar and I was wondering if it's possible to intregrate this in my current html page which scrolls with jquery, using the anchor tag. What I would like is the following: At this moment I have