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 ...

Similar Messages

  • How can we use Session Variable in Answers or Analysis?

    How can we use Session Variable in Answers or Analysis?

    Again, duplicate cross-posting!
    See rukbat 's post here: Re: BI Apps 7.9.6.3(Agent Issue)

  • How set a SESSION variable?

    How set a SESSION variable?
    There is a standard object where could do this?
    Thx in advance Roberto.

    >I'm not at all sure that you CAN change the portal language in the way that you want.
    >Perhaps you should repost this question in the portal forum.
    No i manage the language of WebDynpro myself, with tables from R3.
    I wanna do only a thing like HTTP SESSION variable from the WEB.
    I could do it, using java function of servlet, but i don't wanna use third packege out of WebDynpro FRAMEWORK.
    The isn't an OBJECT CLASS STANDARD od WebDynpro that do that?
    I wanna PERMANENT variable from a WebDynpro to another.
    It is an implicit variable passage.
    No one did something of similar?
    Bye
    Message was edited by: giovanni angerame

  • How to pass session variable value with GO URL to override session value

    Hi Gurus,
    We have below requirement.Please help us at the earliest.
    How to pass session variable value with GO URL to override session value. ( It is not working after making changes to authentication xml file session init block creation as explained by oracle (Bug No14372679 : which they claim it is fixed in 1.7 version  Ref No :Bug 14372679 : REQUEST VARIABLE NOT OVERRIDING SESSION VARIABLE RUNNING THRU A GO URL )
    Please provide step by step solution.No vague answers.
    I followed below steps mentioned.
    RPD:
    ****-> Created a session variable called STATUS
    -> Create Session Init block called Init_Status with SQL
        select 'ACTIVE' from dual;
    -> Assigned the session variable STATUS to Init block Init_Status
    authenticationschemas.xml:
    Added
    <RequestVariable source="url" type="informational"
    nameInSource="RE_CODE" biVariableName="NQ_SESSION.STATUS"/>
    Report
    Edit column "Contract Status" and added session variable as
    VALUEOF(NQ_SESSION.STATUS)
    URL:
    http://localhost:9704/analytics/saw.dll?PortalGo&Action=prompt&path=%2Fshared%2FQAV%2FTest_Report_By%20Contract%20Status&RE_CODE='EXPIRED'
    Issue:
    When  I run the URL above with parameter EXPIRED, the report still shows for  ACTIVE only. The URL is not making any difference with report.
    Report is picking the default value from RPD session variable init query.
    could you please let me know if I am missing something.

    Hi,
    Check those links might help you.
    Integrating Oracle OBIEE Content using GO URL
    How to set session variables using url variables | OBIEE Blog
    OBIEE 10G - How to set a request/session variable using the Saw Url (Go/Dashboard) | GerardNico.com (BI, OBIEE, O…
    Thanks,
    Satya

  • Using value variables throw public functions

    He all!!
    I'm trying to use value variables throw public functions in
    the same class.
    Is there any possible to do it?
    I'll explain:
    What i whant is in tha FLA file to get the songName of the
    mp3 like trace(musica.nomeMusica);
    quote:
    //AS Code
    package Mp3Player{
    import flash.media.Sound;
    import flash.media.SoundLoaderContext;
    import flash.media.SoundChannel;
    import flash.media.ID3Info;
    import flash.net.URLRequest;
    import flash.events.Event;
    public class Mp3Player {
    private var sound:Sound;
    private var req:URLRequest;
    private var context:SoundLoaderContext;
    private var channel:SoundChannel;
    private var id3:ID3Info;
    private var nomeMusica:String;
    public function tocarMusica(file) {
    sound=new Sound ;
    req=new URLRequest(file);
    context=new SoundLoaderContext(8000,true);
    sound.load(req,context);
    channel=sound.play();
    trace("A tocar");
    sound.addEventListener(Event.ID3,id3Info);
    public function id3Info(event:Event):void {
    id3=event.target.id3;
    nomeMusica=id3.songName;
    public function get getNome():String {
    return nomeMusica;
    //FLA Code
    import Mp3Player.Mp3Player;
    var musica:Mp3Player = new Mp3Player();
    var nome:String = musica.getNome;
    musica.tocarMusica("Saia_Indiscreta.mp3");
    trace(nome);
    The trace of my code is:
    quote:
    A tocar
    Null
    What i'm doing wrong or is missing?

    Tnks all for the reply but none of them give me any answer :(
    Making the question in other way.
    Using the code above, how can i set a funcion to call the
    musicaNome value from FLA file?
    quote:
    //AS Code
    package Mp3Player{
    import flash.media.Sound;
    import flash.media.SoundLoaderContext;
    import flash.media.SoundChannel;
    import flash.media.ID3Info;
    import flash.net.URLRequest;
    import flash.events.Event;
    public class Mp3Player {
    private var sound:Sound;
    private var req:URLRequest;
    private var context:SoundLoaderContext;
    private var channel:SoundChannel;
    private var id3:ID3Info;
    private var nomeMusica:String;
    public function tocarMusica(file) {
    sound=new Sound ;
    req=new URLRequest(file);
    context=new SoundLoaderContext(8000,true);
    sound.load(req,context);
    channel=sound.play();
    trace("A tocar");
    sound.addEventListener(Event.ID3,id3Info);
    public function id3Info(event:Event):void {
    id3=event.target.id3;
    nomeMusica=id3.songName;

  • Can we use session variables in BI publisher's Data Model SQL Query?

    Hi Experts,
    We need to implement Data level security in BI Publisher 11g.
    In OBIEE we do so by using session variables, so just wanted to ask if we can use the same session variables in BI Publisher as well
    ie can we include the where clause in the Data Models SQL Query like
    Where ORG_ID = @{biServer.variables['NQ_SESSION.INV_ORG']}
    Let me know your views on this.
    PS: We are implementing EBS r12 security in BI Publisher.
    Thanks

    Read this -> OBIEE 11g: Error: "[nQSError: 23006] The session variable, NQ_SESSION.LAN_INT, has no value definition." when Creating a SQL Query using the session variable NQ_SESSION.LAN_INT in BI Publisher [ID 1511676.1]
    Follow the ER - BUG:13607750 - NEED TO BE ABLE TO SET A SESSION VARIABLE IN OBIEE AND USE IT IN BI PUBLISHER
    HTH,
    SVS

  • Use Session Variable with row-wise initialization

    Hello,
    I use an initialization block in order to load some translations in my repository (version is 11.1.1.6.BP1) :
    SQL :
    SELECT CODE_KEY, STRING_VALUE FROM "TABLES" WHERE  LANGUAGE_KEY= 'VALUEOF(NQ_SESSION.USERLOCALE)'
    Values :
    CN_INCOMING, Incoming, en
    CN_OUTGOING, Outgoing, en
    CN_INCOMING, Réception, fr
    CN_OUTGOING, Emission, fr
    etc ...
    I checked the row-wise intialization.
    The query is correct and returns the right values (I check in the log file ..).
    So far, So good.
    But when I want to use session variables in a column expression (in repository) like  :
    CASE WHEN "column"="xx" THEN VALUEOF(NQ_SESSION."CN_INCOMING")  ELSE VALUEOF(NQ_SESSION."CN_OUTGOING") END
    I got the error: [nQSError: 23006] The session variable, NQ_SESSION.CN_OUTGOING, has no value definition.
    If I used the same formula directly in Answers it's working correctly.
    Do I have to necessarily do this in answers or is there a way to do this in the repository.
    Thanks in advance
    Regards
    Benjamin

    Yes I already tested this point, when I don't use a row wise initialization it's working, but I don't want to create one variable for each translations that I need to use in column formula if you know what I mean.
    I don't understand why we can't use this kind of variable in this context ..but if I have to create the column in my analysis, I will do that, but it's not really user friendly
    Anyway thanks for your time.

  • Page Specific Persistence using Session Variables

    Hi, I have read a lot about using session variables to persist the ReportDocument object across page loads.  This works fine if you have just one page open with one report.  The problem I am having is I have a web application that makes 30 or 40 different reports available to the user.  To simplify the code and make it easier to add new reports I have developed a single template aspx page that can be used to view any of the reports.
    My problem is that if the user opens 2 different reports in 2 separate tabs in the browser then the session variable persistence doesn't work because the session variable is available to both tabs.
    Is there a way to persist the ReportDocument object which is 'page' specific.
    Thanks

    Your best option is likely to have something that makes the session variable names unique.  I've done such things as putting the current datetime in the url as a querystring parameter and appending that to the variable name.  On each postback that querystring should persist.
    You might be able to use the reportclientdocument object and serialize the report and persist through view state, haven't tried this with inproc ras though.  A sample that uses the ras sdk can be found [here|http://wiki.sdn.sap.com/wiki/display/BOBJ/NETRASSDK+Samples]

  • Dates Format in Promts using Session Variables

    Hi Experts,
    I have an issue in controlling date format in prompts using session variable which I am using to set default value.
    By default date format is timestamp E.g '2010-12-19 12:00:00 AM'.
    As per requriement(s) I customized the date format in Reports as 19-Dec-2010 and I saved it as "System Wide Default for <Date Column Name> "
    So, I got desired format in Reports and Date Prompts.
    Now, I need to set a default value in Date Prompt. So, in RPD I created a Session Variable which returned me date in
    DD-MON-YYYY format. Using follwing SQL :
    SELECT REPLACE(CONVERT(VARCHAR(11), Getdate (), 106), ' ', '-') AS [DD-Mon-YYYY]
    But in reports takes this value as string and not Datetime. So i got an error message.
    A datetime value was expected (received "19-Dec-2010").
    If i do not use above SQL to CONVERT date then default date in prompt get displayed as timestamp format and give me desired results but Formatting looks very odd in prompt
    Is this a way so I can persist the [DD-Mon-YYYY] Formatting for default value which comes using variable and still run the report.
    Above problem also exist vice versa that is if i SET that session variable and pass the datetime value to server. But there i guess I can use ToDate or some Casting in RPD column expression to handle that. Tell me if i am right ?
    Thanks
    Saurabh

    That almost works. I had to adjust the syntax to the following...and then there are other issues doing this.
    select cust_no, name,'@{session.currentUser}' from customersMy write-back SQL is this:
    UPDATE customers SET NAME='@{c1}',LAST_EDITED_BY='@{c2}' WHERE CUST_NO=@{c0}But I don't want to display the cust_no column to the user. So I hide it in the UI. But if I do that I get the below error during write-back. Apparently sometimes when you hide a column on a direct query (numeric maybe?) the value doesn't transfer over to the write-back. If that's the case, this won't work for me. Hmm...
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43093] An error occurred while processing the EXECUTE PHYSICAL statement. [nQSError: 17001] Oracle Error code: 936, message: ORA-00936: missing expression at OCI call OCIStmtExecute: UPDATE customers SET NAME='Wyatt Donnely',LAST_EDITED_BY='Administrator' WHERE CUST_NO= . [nQSError: 17011] SQL statement execution failed. (HY000)
    SQL Issued: EXECUTE PHYSICAL CONNECTION POOL dev1 UPDATE customers SET NAME='Wyatt Donnely',LAST_EDITED_BY='Administrator' WHERE CUST_NO=

  • How to a session variable in another initialisation block?

    Hello all,
    I think I overlook something. So hope someone please can help me out.
    I have 2 initialisation blocks.
    The first one has as a source a LDAP server.
    Now I fill a session variable called mail by the LDAP server.
    When I click on test I will see my mail address.
    lets say I see [email protected]
    No I want to do something with that subdomain.
    So I made a new initialisation block with the database as the source.
    And made a query
    select case when upper(:mail) like 'subdomain%' then A else 'NO Domain found' END from dual
    but this doesn't work, and really don't understand why!! (and ofcourse I am using the executed precendence option to initialise first the other initaialisation block)
    also when I change the query in:
    select case when upper('[email protected]') like 'SUBDOMAIN%' then A else 'NO Domain found' END from dual
    then it al works fine..
    Hope anyone can help me out!!
    Best regards,
    Remc0

    Does the Init Block really fails? Could you please set the logging level to 2 in that user and review both the NQuery and Presentation Services log files? Can you try with a simply select statement:
    SELECT upper(VALUEOF(NQ_SESSION.MAIL)) FROM DUAL
    to make sure the new variable is getting initialized? It could be that the value from the LDAP server has trailing or leading spaces?
    Also I don't see why you need to put the domain on another session variable, you could do your filter using the case statement directly. Unknown to many a CASE statement can be used in a WHERE clause as well. Sample SQL:
    WHERE COLUMN = (case when upper(VALUEOF(NQ_SESSION.MAIL)) like '%SUBDOMAINY%' then 'SUBDOMAINY' else 'NO Domain found' END)

  • Sticky using session variables

    Hello
    I was wondering if it is possible to stick a session to a server using session variables (such as username) Currently I am using cookies to keep the session sticky but i also need to use the session variables.
    Thanks
    Donagh

    Donagh,
    there is absolutely no reason to use both.
    If the name is more important, than use the name.
    If the cookie is more important, than use the cookie.
    If one is not more important than the other, then keep using the cookie.
    Another way to see it is :
    if the name and the cookie refer to the same server, it does not matter which one you use.
    But if they point to different servers.
    What do you do ?
    Which information do you use to select the server ?
    The name or the cookie ?
    As I said, there is no reason to use both.
    Unless if one is missing.
    But the problem is then to make sure it is always there.
    Is there any stickyness issue currently ?
    Gilles.

  • 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

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

  • How to default bind variable using session variable at run time

    Hi All,
    I have a requirement where all VO queries (multiple VOs) produce only records that meet a certain value.
    For example, I have three tables with 3 VOs and each of them has a one-to-many relationship to another table (let's call it ref table and this table has a field called release). One of the 3 VOs is a parent/master table, and the other two are child tables. I created a VO for master table that linked to the ref table and created a view criteria using the release (use bind variable) field from the ref table. The other child tables have their own VO that has view criteria that also linked to ref table using the release field.
    On the UI page, I created a query component and a table from the master table VO. I also dropped the child table VOs in a tabbed panel which partial triggered by the master table. When I ran a query for a 'release' (hint: ref table value), the table for master table was filled the correct records that meet the criteria. Unfortunately, the child tables were not correct due to the query didn't use the bind variable that filter only records for the same 'release' value as the master table.
    The question is how do I 'default' or dynamically set the bind variable on the child tables based on the selection criteria from the query component. I am thinking to set a session variable from the query and use it in the bind variable in the child table, but not sure how to do it.
    Any suggestion how to do it or better solution to achieve the same effect?

    Hi,
    How about creating a custom AMImpl method, that takes parameters as required, and set the bind variables for all the desired VOs and perform executeQuery on them.
    You could expose this as client interface, and then use the method as parameter form.
    Check this thread for ex.
    Re: Setting Attribute in View Object through Managed Bean
    -Arun

  • How do i filter recordsets using session variable???  Please help this is driving me mad...!!

    I am having the same problem as user "Gabe the animator" in a post sent in 2007.
    "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???"
    here is the code:
    <?php require_once('Connections/mockconn.php'); ?>
    <?php
    session_start();
    ?>
    <?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;
    if(!session_id()){
    session_start();
    $colname_info = "-1";
    if (isset($_SESSION['email'])) {
      $colname_info = $_SESSION['email'];
    mysql_select_db($database_mockconn, $mockconn);
    $query_info = sprintf("SELECT name, last_name, email, password FROM registration WHERE email = %s", GetSQLValueString($colname_info, "text"));
    $info = mysql_query($query_info, $mockconn) or die(mysql_error());
    $row_info = mysql_fetch_assoc($info);
    $totalRows_info = mysql_num_rows($info);
    ?>
    <!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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>home</title>
    </head>
    <body>
    <div id="info">hello <?php echo $row_info['']; ?></div>
    <?php
    if (isset($_SESSION['email'])) {
              echo 'your email: '.' '. $_SESSION['email'] .' '.'good job';}
                        ?>
    </body>
    </html>
    PLEASE PLEASE HELP.... I have been at this for day's...
    how do I get the record set to filter based on the value of the session variable

    Sorry I forgot to mension the error I am getting?
    ( ! ) Notice: Undefined index: in C:\wamp\www\mock\home.php on line 59
    Call Stack
    Time
    Memory
    Function
    Location
    1
    0.0093
    389024
    {main}( )
    ..\home.php:0
    Why is this error coming up?

Maybe you are looking for

  • Is it possible to add a second internal hard drive to my 27" iMac?

    Just wondering if the above is possible. If so could anyone recommend which hard drives to use (which are available in the UK) Thanks in advance.

  • Payment order use different check

    I already create check using fch5, for one payment order. now I want to create another check for that payment order, what steps should I do if I don't want to void the old check?

  • Kodo 4.1.2 license key problem

    Has anyone tried the JDO tutorial provided with Kodo 4.1.2? Everything works fine until I try to create the mappings with 'mappingtool -p jdo.properties package.jdo'. Then I get: Exception in thread "main" com.solarmetric.license.LicenseException: No

  • FM for billing doc pricing condition

    Hi is there a Fm that returns all the pricing conditions for a billing document (Header and line items) with the condition types and the amounts?? I tried to use the FM RV_INVOICE_DOCUMENT_READ, but i think this FM does not return the condition types

  • Full screen view background color Pages 5.5.1

    Is there a way to change the background color in Full Screen View back to black in Pages 5.5.1? I do not prefer the new default grey and would like to change it. I found a similar question in the forum for an earlier version of pages the pointed to a