Hashcode() of value called during session.setAttribute() why?

When I set a Vector value into session hashCode() is called on the elements of the Vector? Why?
In the code below, MyObject extends a base class that has the following implementation of hashCode() so as to enforce its implementation in all it's children if and only if it is required (i.e. not really a case for an abstract class as I want to try to avoid its implementation).
public int hashCode () {
    throw new RuntimeException("hashCode is not supported in base class");          
}What I find is the following code throws the hashcode exception on the 2nd set of Key1, but I dont understand why. Why is hashCode() called on the elements of the vector? is this some set optimization - i.e. it does not update session if the objects are the same?
Vector v1 = new Vector();
v1.add( new MyObject( someUniqueParam1 ) );
v1.add( new MyObject( someUniqueParam2 ) );
Vector v2 = new Vector();
v2.add( new MyObject( someUniqueParam1 ) );
v2.add( new MyObject( someUniqueParam2 ) );
session.setAttribute( "Key1", v1 ); // successful
session.setAttribute( "Key2", v2 ); // successful
session.setAttribute( "Key1", v2 ); // exception thrown from MyObject - why?Please help me understand? My workaround for the moment is to call session.removeValue() first.

The hashCode() method in Vector calls hashCode() in its superclass (AbstractList) which calls hashCode() on each of the objects stored in the List. It looks as if the servlet container calls hashCode() on the object being added as a session attribute when the key is already present. Why this happens is anyone's guess (checking if object is same as the one currently stored?) and is probably servlet engine specific.
Overriding hashCode() to throw an exception is probably not a good idea as many Java classes call hashCode() "behind the scenes" which is why the default implementation is part of Object. Can you use that default implementation?

Similar Messages

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

    I 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 ??

  • Newscale Custom Code - AJAX Libraries - Web Service calls during ordering moment

    Authentication issues calling webservice that requires credentials to be passed. NTLM authentication. Web service we are calling works from Service Link with HTTPIWA2 adapter.This is on Windows environment. When in the ordering moment, i am being presented with a popup box asking for credentials.
    We are implementing a custom Newscale solution for Web Service calls during the ordering moment. I've installed and got the basic example working on our Windows based system. However, I'm trying to implement a more complex web service call that includes supplying credentials- domain userid password encrypted in the xdsproperties file. The web service we are calling has been successfully called by the service link HTTPIWA2 adapter, and independently using SOAP Sonar, so i don't feel the problem is with the web service.
    We are on a windows based server and the web service we are calling is on windows as well. In the ordering moment the web service is being called, but I'm being presented with popups asking for credentials for the server that Request Center is on.
    Has anyone successfully used this AJAX solution calling a web service using NTLM authentication?  I'd like to compare configurations to see what is missing. You can email me directly at [email protected]  Newscale PSG is on the case, but i was hoping to touch base with any other customers currently using this.
    thanks!

    A newer version of the Configuration Manager Client is installed. Cannot continue installing this version of the management point.
    Action ended 20:50:23: SmsDetectColocationDowngrade. Return value 3.
    Action ended 20:50:23: INSTALL. Return value 3.
    The installer certainly thinks that you still have a previous ConfigMgr client installed. Perhaps you haven't completely removed it. Use ccmclean.exe from the SMS 2003 tool kit.
    If that fails, why not just rebuild the server - you've said that this is a fresh install. I don't like too much messing at the beginning. This can be difficult enough - you need to start with a clean installation of the product.
    Gerry Hampson | Blog:
    www.gerryhampsoncm.blogspot.ie | LinkedIn:
    Gerry Hampson | Twitter:
    @gerryhampson

  • Having trouble with session.setAttribute()

    Hi,
    I'm trying to attach the current time to the sessionID as follows but it is not working.
    long stime = System.currentTimeMillis() / 1000;
    session.setAttribute("stime", stime);
    Then I want to call it later on....
    long stime = session.getAttribute("stime");
    None of this is working. Can someone help me please...
    thanks,
    kramer

    Hello,
    Capital "L" Long is the Object representation or "wrapper" of a long (lowercase "l"), which is one of the basic types called primitives and is a reserved keyword in the Java Language.
    As for uses, if you are simply dealing with long values in terms of basic arithmetic functions (+, -, *, /, etc.) then the primitive type will work fine. If you need to do fancier things, like conversion to another type, String representations, storage in a HashMap as an Object, etc. then that is for what the wrapper class is intended.
    Good luck,
    Ken

  • Session.putValue() and session.setAttribute

    do I have to use session.putValue() before using session.setAttribute() and session.getAttribute() ?
    becuase I have one JSP page include one form (action=TheSameJspFile.JSP) several Submit bottuns each Bottun has its Value.
    in the JSP I request the submit value and depends on it doing stuff ...
    each Value I have to get and to set a session Attribute, if I want to putValue it will delete the old value.
    how can I solve this?

    You need to store something in the session before you can retrieve it.
    So, you need to do a setAttribute() to place something in the session. Then you use getAttribute() to retrieve it. DO NOT use putValue as it is deprecated and has been replaced by setAttribute(). DO NOT use getValue() as it is deprecated and has been replaced by getAttribute().

  • How to Use synchronous RFC calls during test run for remote accesses

    there is a Setting for the usage of RFC accesses from a tested system
    using eCATT.
    'X' - Use asynchronous RFC calls during test run for remote accesses
    ' ' - Use synchronous RFC calls during test run for remote accesses
    I developed an eCATT as following :
      SAPGUI ( SAPGUI_1 , Target_system_1 ).
      SAPGUI ( SAPGUI_2 , Target_system_2 ).
    My question is how to run the eCATT in a synchronous RFC calls
    PS: I do not want to change the Target_system to the same one in the
    above script of ecatt.Because I need to run it in 2 different Target
    systems sometime.
    for example, I give a Target_system_3 when run this eCATT
    I want the SAPGUI_1 and SAPGUI_2 run the Target_system_3 but not the
    Target_system_1 or Target_system_2 .
    Could you please tell me how to make it without the changes in script?
    Edited by: Weitong Liu on Mar 24, 2011 9:44 AM

    Hi Liu,
    Weitong Liu wrote:
    > ' ' - Use synchronous RFC calls during test run for remote accesses
    This is the standard option value. Asynchronous are not the standard way and used only for very special purposes.
    Weitong Liu wrote:
    > I developed an eCATT as following :
    >   SAPGUI ( SAPGUI_1 , Target_system_1 ).
    >   SAPGUI ( SAPGUI_2 , Target_system_2 ).
    > My question is how to run the eCATT in a synchronous RFC calls
    The commands will be executed in sequence. So each call will be synchronously replayed against TS1 and TS2.
    What is you issue with this standard procedure?
    Kind regards,
    Christoph

  • How far session.setAttribute("user",user) is safe for login checks

    hi,
    i would like to discuss how far the method of session.setAttribute() can save
    unauthorized access of pages. as far as i know when a user logs in we set a
    session attribute say user and set its value to the entered username.
    To prevent the unauthorized access of inner pages i would check at the beginning of every page whether the user attribute is null or not by getAttribute("user") method. if it is null i wont allow the user to open the page.
    Can i rely on this strategy to write my web pages or does it have any bugs through which user can hack the page or any other better way to secure the pages.
    thanx

    That's pretty standard. I wouldn't go so far to say it couldn't be hacked, but generally that would require some bug in your login process or direct access to the server and it's memory. The latter certainly isn't possible remotely. The former, as long as you know that the attribute can't be added when it shouldn't, then it should be fine.

  • Problem in session.setAttribute    (like the other user!)

    Hello,
    when JSP is invoked by the servlet it found ID = null
    My Servlet has this code ( I tried to let connection and statement open like you said in another post, but nothing)
    The worse thing is that, the first time I tried this code, it worked!
    public class Login extends HttpServlet{
         private Connection con;
         private Statement st;
         private ResultSet rs,rs2;
         public void doGet(HttpServletRequest req,HttpServletResponse res) {
              try{
              Class.forName("com.mysql.jdbc.Driver");
              con=DriverManager.getConnection("jdbc:mysql://localhost:3306/gecoprova","root","argoilcane");
              st=con.createStatement();     
              rs=st.executeQuery("SELECT * FROM anagrafe_procuratori WHERE ragsoc='"+req.getParameter("ID")+"'");          
              if(rs!=null){
                   if(rs.next())try {
                        st=con.createStatement();
                        rs2=st.executeQuery("SELECT * FROM privilegi_procuratore WHERE (userid='"+req.getParameter("ID")+"' AND pass='"+req.getParameter("pass")+"')");
                        if(rs2!=null){
                             if(rs2.next())try {
                                            HttpSession session=req.getSession(true);
                                            String ID=req.getParameter("ID");
                                            String pass=req.getParameter("pass");
                                              session.setAttribute(pass,pass);
                                            session.setAttribute(ID,ID);
                                            // rs2.close();     
                                            // con.close();
                                            String url = res.encodeRedirectURL("Inserimento.jsp");
                                            res.sendRedirect(url);
                   }catch (Exception e){e.printStackTrace();}
                   res.sendRedirect("errorlogin.html");
              else{
                   res.sendRedirect("errorlogin.html");
                   }catch (Exception e){e.printStackTrace();}
                   res.sendRedirect("errorlogin.html");
              else{
                   res.sendRedirect("errorlogin.html");
              res.sendRedirect("errorlogin.html");
              catch(Exception e){
                   try {
                        e.printStackTrace();
                        res.sendRedirect("errorlogin.html");
                   catch(Exception e1){}
         }

    Hello,
    when JSP is invoked by the servlet it found ID =
    null
    My Servlet has this code ( I tried to let connection
    and statement open like you said in another post, but
    nothing)
    The worse thing is that, the first time I tried this
    code, it worked!
    public class Login extends HttpServlet{
         private Connection con;
         private Statement st;
         private ResultSet rs,rs2;
    public void doGet(HttpServletRequest
    t req,HttpServletResponse res) {
              try{
              Class.forName("com.mysql.jdbc.Driver");
              con=DriverManager.getConnection("jdbc:mysql://localh
    ost:3306/gecoprova","root","argoilcane");
              st=con.createStatement();     
    rs=st.executeQuery("SELECT * FROM
    OM anagrafe_procuratori WHERE
    ragsoc='"+req.getParameter("ID")+"'");          
              if(rs!=null){
                   if(rs.next())try {
                        st=con.createStatement();
    rs2=st.executeQuery("SELECT * FROM
    FROM privilegi_procuratore WHERE
    (userid='"+req.getParameter("ID")+"' AND
    pass='"+req.getParameter("pass")+"')");
                        if(rs2!=null){
                             if(rs2.next())try {
                                            HttpSession session=req.getSession(true);
                                            String ID=req.getParameter("ID");
                                            String pass=req.getParameter("pass");
                                              session.setAttribute(pass,pass);
                                            session.setAttribute(ID,ID);
                                            // rs2.close();     
                                            // con.close();
    String url =
    ng url = res.encodeRedirectURL("Inserimento.jsp");
                                            res.sendRedirect(url);
                   }catch (Exception e){e.printStackTrace();}
                   res.sendRedirect("errorlogin.html");
              else{
                   res.sendRedirect("errorlogin.html");
                   }catch (Exception e){e.printStackTrace();}
                   res.sendRedirect("errorlogin.html");
              else{
                   res.sendRedirect("errorlogin.html");
              res.sendRedirect("errorlogin.html");
              catch(Exception e){
                   try {
                        e.printStackTrace();
                        res.sendRedirect("errorlogin.html");
                   catch(Exception e1){}
    hi ...
    i think u retrive the session information in jsp like this ....
    session.getAttribute("ID");
    session.getAttribute("pass");
    if this so .. then u made a mistake in ur servlet code
    check wat u write in ur servlet
    String ID=req.getParameter("ID");
    String pass=req.getParameter("pass");
    session.setAttribute(pass,pass);
    session.setAttribute(ID,ID);
    the first argument of setAttribute method is used as key ... which u set as ID and pass .. but b4 that u set ID and pass to string values that r coming from request...
    change the code in servlet to this
    String ID=req.getParameter("ID");
    String pass=req.getParameter("pass");
    session.setAttribute("pass",pass);
    session.setAttribute("ID",ID);
    i think it will work now
    session.getAttribute("ID");
    session.getAttribute("ID");

  • The solutinons to value mapping during exchanging

    Howdy!
    Here's the general senario:
    We got a 3rd party system named KS and a local R3 system called RS. We have a interface that send invoice data from KS to RS. But the customer number from KS is different from RS customer number, so we need not noly the structure/format mapping but also the value mapping during exchanging procedure.
    Anyone got a proper solution to this problem?
    3Q!

    hi,
    1. 2 problems with value mappings:
    - if you don't use value mapping replication you will have to add all of them
    (one by one) to a table in directory - very time consuming
    - you cannot have two records with the same value pointing to one target value !
    (so if in one system two numbers will mean one number in SAP this will not work)
    2. so try considering other forms of lookups
    - lookups from user functions - message mappings
    - lookups from ABAP - abap mappings
    - lookups from ABAP - XSLT on ABAP stack
    Regards,
    michal

  • Maintenance Optimizer Error "Value loss during allocation"

    Hi Everybody,
    like Error when Launching the Maintenance optimizer, i am facing the same problem with SolMan 7.1. Is there anything new?
    System is new installed.
    SOLMAN_SETUP is executed.
    BC Set for MOPZ are activeded.
    SMSY is arranged.
    MOPZ is aborting after calculation the target with
    On Web:
    The followin error text was processed in SOL the systm: Value loss during allocation.
    The error occurred on the application server _______ and in the work process. 7
    The termination type was: RABAX_STATE
    The ABAP call hierarchy was:
    Method: GET_2ND_CHECK_RESULT of program CL_MO_SMP_ADAPTER=============CP
    Method: LOAD_IMPACT_ASC of program /1BCWDY/06BL1VDEKWGU61REAXHZ==CP
    Method: LOAD_22 of program /1BCWDY/06BL1VDEKWGU61REAXHZ==CP
    Method: LOAD_CONTEXT of program /1BCWDY/06BL1VDEKWGU61REAXHZ==CP
    Method: IF_COMPONENTCONTROLLER~LOAD_CONTEXT of program /1BCWDY/06BL1VDEKWGU61REAXHZ==CP
    Method: HANDLEDEFAULT of program /1BCWDY/06BL1VDEKWGU61REAXHZ==CP
    Method: IF_WDR_VIEW_DELEGATE~WD_INVOKE_EVENT_HANDLER of program /1BCWDY/06BL1VDEKWGU61REAXHZ==CP
    Method: INVOKE_EVENTHANDLER of program CL_WDR_DELEGATING_VIEW========CP
    Method: NAVIGATE of program CL_WDR_CLIENT_APPLICATION=====CP
    Method: DO_NAVIGATION of program CL_WDR_WINDOW_PHASE_MODEL=====CP
    On ST22:
    Category               ABAP Programming Error
    Runtime Errors         CONVT_DATA_LOSS
    Except.                CX_SY_CONVERSION_DATA_LOSS
    ABAP Program           CL_MO_SMP_ADAPTER=============CP
    Application Component  SV-SMG-MAI
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_CONVERSION_DATA_LOSS', was not
         caught in
        procedure "GET_2ND_CHECK_RESULT" "(METHOD)", nor was it propagated by a RAISING
         clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        Value "01200615325000005298|01200314694900012246:01200314694900010013" was
         allocated in a field which is not long enough.
        Therefore the target field could not store all information of
         "01200615325000005298|01200314694900012246:01200314694900010013".

    Hello Espartaco,
    I have the same problem, too. Have there been a response to your OSS message?
    With best regards
    Frank Lehmann

  • Can i store the Result set values as a Session variable

    hai,
    I want the result set values of a query to be used many times and I want the same resultset between different page calls.
    I want all those records fetched from the database to be available in the next page with out refetching from the database.
    can any one help me out. its very urgent.....
    Thanks and regards,
    Ravikiran
    mail to me at : [email protected]

    "can i store the Result set values as a Session variable "
    Practically Yes u can
    but u want be able to accesses it in other pages
    u can try it and see
    the other thing u can do is store the values from the resultset in a object say vector and put vector in seesion and u can use this any where
    for e.g
    Vector v=new Vector();
    While(rs.next())
    v.addElement(rs.getString(1));
    v.addElement(rs.getString(2));
    session.putValue("myVector",v);
    now where u want to get it do this
    Vector myvec=(Vector)session.getValue("myVector");
    do do futher

  • Calling new session

    hi Friends,
    i am using the FM ABAP4_CALL_TRANSACTION' STARTING NEW TASK 'TEST' for calling new session FK03 tcode and Skip the frist screen, i have passed 2 parameters lifnr(LIF) and bukrs(BUK).This Values coming with NEW session, but in FK03 frist screen check box are there for Address data, it is asking Select at least one processing option,
    how to select the processing option. please give me solution.
    Thanks,
    santha

    Hi, you will need to do a partial BDC here.  Please test out the example below. 
    report zrich_0001.
    data: messtab like bdcmsgcoll occurs 0 with header line,
          bdcdata like bdcdata occurs 20 with header line,
          mode(1) type c value 'E'.
    parameters: p_lifnr type rf02k-lifnr,
                p_bukrs type rf02k-bukrs.
    perform bdc_dynpro      using 'SAPMF02K' '0106'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RF02K-D0610'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RF02K-LIFNR'
                            p_lifnr.
    perform bdc_field       using 'RF02K-BUKRS'
                            p_bukrs.
    * These are the checkboxes
    perform bdc_field       using 'RF02K-D0110'
                                  'X'.
    perform bdc_field       using 'RF02K-D0120'
                                  'X'.
    perform bdc_field       using 'RF02K-D0130'
                                  'X'.
    perform bdc_field       using 'WRF02K-D0380'
                                  'X'.
    perform bdc_field       using 'RF02K-D0210'
                                  'X'.
    perform bdc_field       using 'RF02K-D0215'
                                  'X'.
    perform bdc_field       using 'RF02K-D0220'
                                  'X'.
    perform bdc_field       using 'RF02K-D0610'
                                  'X'.
    call function 'ABAP4_CALL_TRANSACTION'
      starting new task 'TEST'
               exporting
                 tcode                         = 'FK03'
                 mode_val                      = mode
                 update_val                    = 'S'
               tables
                 using_tab                     = bdcdata
    *                mess_tab                      = messtab
               exceptions
                 call_transaction_denied       = 1
                 tcode_invalid                 = 2
                 others                        = 3.
    *      Form  BDC_DYNPRO
    form bdc_dynpro using  program dynpro.
      clear bdcdata.
      bdcdata-program = program.
      bdcdata-dynpro = dynpro.
      bdcdata-dynbegin = 'X'.
      append bdcdata.
    endform.
    *      Form  BDC_FIELD
    form bdc_field using fnam fval.
      clear bdcdata.
      bdcdata-fnam = fnam.
      bdcdata-fval = fval.
      append bdcdata.
    endform.
    Regards,
    Rich Heilman

  • Combination of call transaction & session methods

    hi,
    how to combine call transaction & session methods in a single transaction.
    give me the exact steps to proceed with the above.

    Hi Saritha,
    Your question is not clear to me but I am assuming your queestion like this
    "Providing choice for user for using either call transaction & Session method for uploading data"
    When you generate the BDC (Batch Data Communication options define the processing mode for a batch input session) program with SHDB, you can remove a lot of unwanted fields by copying this customize abap include program.  It allows you to execute the BDC program immediately without filling up those SAP generate fields.  To run background, just run it as a background job.
    Execute BDC immediately by replacing the include BDCRECX1
    Written by : SAP Basis, ABAP Programming and Other IMG Stuff
                     http://www.sap-img.com
    ***INCLUDE ZBDCRECX1.
    When you generate the program using SHDB, you can replace it
    with this if you want to execute it immediately without having
    to process it using SM35.
    During testing you can used the original include.
    For example,
    include zbdcrecx1.   "After test
    include bdcrecx.     "Before test
    Declare your internal table as RECORD
    for programs doing a data transfer by creating a batch-input session
    and
    for programs doing a data transfer by CALL TRANSACTION USING
    *SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS SESSION RADIOBUTTON GROUP CTU.  "create session
    SELECTION-SCREEN COMMENT 3(20) TEXT-S07 FOR FIELD SESSION.
    selection-screen position 45.
    PARAMETERS CTU RADIOBUTTON GROUP CTU DEFAULT 'X'. "call transaction
    SELECTION-SCREEN COMMENT 48(20) TEXT-S08 FOR FIELD CTU.
    *SELECTION-SCREEN END OF LINE.
    PARAMETERS: SESSION NO-DISPLAY,
                CTU     NO-DISPLAY DEFAULT 'X'.
    *SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(20) TEXT-S01 FOR FIELD GROUP.
    selection-screen position 25.
    PARAMETERS GROUP(12).                      "group name of session
    SELECTION-SCREEN COMMENT 48(20) TEXT-S05 FOR FIELD CTUMODE.
    selection-screen position 70.
    PARAMETERS CTUMODE LIKE CTU_PARAMS-DISMODE DEFAULT 'N'.
                                         "A: show all dynpros
                                         "E: show dynpro on error only
                                         "N: do not display dynpro
    *SELECTION-SCREEN END OF LINE.
    PARAMETERS: GROUP(12) NO-DISPLAY,
                CTUMODE   NO-DISPLAY DEFAULT 'N'.
    *SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(20) TEXT-S02 FOR FIELD USER.
    selection-screen position 25.
    PARAMETERS: USER(12) DEFAULT SY-UNAME.    "user for session in batch
    SELECTION-SCREEN COMMENT 48(20) TEXT-S06 FOR FIELD CUPDATE.
    selection-screen position 70.
    PARAMETERS CUPDATE LIKE CTU_PARAMS-UPDMODE DEFAULT 'L'.
                                         "S: synchronously
                                         "A: asynchronously
                                         "L: local
    *SELECTION-SCREEN END OF LINE.
    PARAMETERS: USER(12) NO-DISPLAY DEFAULT SY-UNAME,
                CUPDATE LIKE CTU_PARAMS-UPDMODE DEFAULT 'L' NO-DISPLAY.
    *SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(20) TEXT-S03 FOR FIELD KEEP.
    selection-screen position 25.
    PARAMETERS: KEEP AS CHECKBOX.       "' ' = delete session if finished
                                         "'X' = keep   session if finished
    SELECTION-SCREEN COMMENT 48(20) TEXT-S09 FOR FIELD E_GROUP.
    selection-screen position 70.
    parameters E_GROUP(12).             "group name of error-session
    *SELECTION-SCREEN END OF LINE.
    PARAMETERS: KEEP        NO-DISPLAY,
                E_GROUP(12) NO-DISPLAY.
    *SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(20) TEXT-S04 FOR FIELD HOLDDATE.
    selection-screen position 25.
    PARAMETERS: HOLDDATE LIKE SY-DATUM.
    SELECTION-SCREEN COMMENT 51(17) TEXT-S02 FOR FIELD E_USER.
    selection-screen position 70.
    PARAMETERS: E_USER(12) DEFAULT SY-UNAME.    "user for error-session
    *SELECTION-SCREEN END OF LINE.
    PARAMETERS: HOLDDATE LIKE SY-DATUM NO-DISPLAY,
               E_USER(12) DEFAULT SY-UNAME NO-DISPLAY.
    *SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 51(17) TEXT-S03 FOR FIELD E_KEEP.
    selection-screen position 70.
    PARAMETERS: E_KEEP AS CHECKBOX.     "' ' = delete session if finished
                                         "'X' = keep   session if finished
    *SELECTION-SCREEN END OF LINE.
    PARAMETERS: E_KEEP NO-DISPLAY.
    *SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 51(17) TEXT-S04 FOR FIELD E_HDATE.
    selection-screen position 70.
    PARAMETERS: E_HDATE LIKE SY-DATUM.
    *SELECTION-SCREEN END OF LINE.
    *SELECTION-SCREEN SKIP.
    PARAMETERS: E_HDATE LIKE SY-DATUM NO-DISPLAY.
    *SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(33) TEXT-S10 FOR FIELD NODATA.
    PARAMETERS: NODATA DEFAULT '/' LOWER CASE.          "nodata
    *SELECTION-SCREEN END OF LINE.
    PARAMETERS: NODATA DEFAULT '/' LOWER CASE NO-DISPLAY.
    *SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(33) FOR FIELD SMALLLOG.
    PARAMETERS: SMALLLOG as checkbox.  "' ' = log all transactions
                                        "'X' = no transaction logging
    *SELECTION-SCREEN END OF LINE.
    PARAMETERS: SMALLLOG NO-DISPLAY.
      data definition
          Batchinputdata of single transaction
    DATA:   BDCDATA LIKE BDCDATA    OCCURS 0 WITH HEADER LINE.
          messages of call transaction
    DATA:   MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
          error session opened (' ' or 'X')
    DATA:   E_GROUP_OPENED.
          message texts
    TABLES: T100.
      at selection screen                                                *
    AT SELECTION-SCREEN.
    group and user must be filled for create session
      IF SESSION = 'X' AND
         GROUP = SPACE OR USER = SPACE.
        MESSAGE E613(MS).
      ENDIF.
      open dataset                                                       *
    FORM OPEN_DATASET USING P_DATASET.
      OPEN DATASET P_DATASET IN TEXT MODE.
      IF SY-SUBRC <> 0.
        WRITE: / TEXT-E00, SY-SUBRC.
        STOP.
      ENDIF.
    ENDFORM.
      close dataset                                                      *
    FORM CLOSE_DATASET USING P_DATASET.
      CLOSE DATASET P_DATASET.
    ENDFORM.
      create batchinput session                                          *
      (not for call transaction using...)                                *
    FORM OPEN_GROUP.
      IF SESSION = 'X'.
        SKIP.
        WRITE: /(20) 'Create group'(I01), GROUP.
        SKIP.
      open batchinput group
        CALL FUNCTION 'BDC_OPEN_GROUP'
             EXPORTING  CLIENT   = SY-MANDT
                        GROUP    = GROUP
                        USER     = USER
                        KEEP     = KEEP
                        HOLDDATE = HOLDDATE.
        WRITE: /(30) 'BDC_OPEN_GROUP'(I02),
                (12) 'returncode:'(I05),
                     SY-SUBRC.
      ENDIF.
    ENDFORM.
      end batchinput session                                             *
      (call transaction using...: error session)                         *
    FORM CLOSE_GROUP.
      IF SESSION = 'X'.
      close batchinput group
        CALL FUNCTION 'BDC_CLOSE_GROUP'.
        WRITE: /(30) 'BDC_CLOSE_GROUP'(I04),
                (12) 'returncode:'(I05),
                     SY-SUBRC.
      ELSE.
        IF E_GROUP_OPENED = 'X'.
          CALL FUNCTION 'BDC_CLOSE_GROUP'.
          WRITE: /.
          WRITE: /(30) 'Fehlermappe wurde erzeugt'(I06).
        ENDIF.
      ENDIF.
    ENDFORM.
           Start new transaction according to parameters                 *
    FORM BDC_TRANSACTION USING TCODE.
      DATA: L_MSTRING(480).
      DATA: L_SUBRC LIKE SY-SUBRC.
    batch input session
      IF SESSION = 'X'.
        CALL FUNCTION 'BDC_INSERT'
             EXPORTING TCODE     = TCODE
             TABLES    DYNPROTAB = BDCDATA.
        IF SMALLLOG <> 'X'.
          WRITE: / 'BDC_INSERT'(I03),
                   TCODE,
                   'returncode:'(I05),
                   SY-SUBRC,
                   'RECORD:',
                   SY-INDEX.
        ENDIF.
    call transaction using
      ELSE.
        REFRESH MESSTAB.
        CALL TRANSACTION TCODE USING BDCDATA
                         MODE   CTUMODE
                         UPDATE CUPDATE
                         MESSAGES INTO MESSTAB.
        L_SUBRC = SY-SUBRC.
        IF SMALLLOG <> 'X'.
         WRITE: / 'CALL_TRANSACTION',
                  TCODE,
                  'returncode:'(I05),
                  L_SUBRC,
                  'RECORD:',
                  SY-INDEX.
          IF SY-SUBRC = 0.
             FORMAT COLOR OFF.
             WRITE:/ 'Successfully Process ', MESSTAB, RECORD.
          ELSE.
             FORMAT COLOR COL_NEGATIVE.
             WRITE:/ 'Failed Process ', MESSTAB, RECORD.
          ENDIF.
          LOOP AT MESSTAB.
            SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA
                                      AND   ARBGB = MESSTAB-MSGID
                                      AND   MSGNR = MESSTAB-MSGNR.
            IF SY-SUBRC = 0.
              L_MSTRING = T100-TEXT.
              IF L_MSTRING CS '&1'.
                REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.
                REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.
                REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.
                REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.
              ELSE.
                REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.
                REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.
                REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.
                REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.
              ENDIF.
              CONDENSE L_MSTRING.
              WRITE: / MESSTAB-MSGTYP, L_MSTRING(250).
            ELSE.
              WRITE: / MESSTAB.
            ENDIF.
          ENDLOOP.
          SKIP.
        ENDIF.
    Erzeugen fehlermappe ************************************************
        IF L_SUBRC <> 0 AND E_GROUP <> SPACE.
          IF E_GROUP_OPENED = ' '.
            CALL FUNCTION 'BDC_OPEN_GROUP'
                 EXPORTING  CLIENT   = SY-MANDT
                            GROUP    = E_GROUP
                            USER     = E_USER
                            KEEP     = E_KEEP
                            HOLDDATE = E_HDATE.
             E_GROUP_OPENED = 'X'.
          ENDIF.
          CALL FUNCTION 'BDC_INSERT'
               EXPORTING TCODE     = TCODE
               TABLES    DYNPROTAB = BDCDATA.
        ENDIF.
      ENDIF.
      REFRESH BDCDATA.
    ENDFORM.
           Start new screen                                              *
    FORM BDC_DYNPRO USING PROGRAM DYNPRO.
      CLEAR BDCDATA.
      BDCDATA-PROGRAM  = PROGRAM.
      BDCDATA-DYNPRO   = DYNPRO.
      BDCDATA-DYNBEGIN = 'X'.
      APPEND BDCDATA.
    ENDFORM.
           Insert field                                                  *
    FORM BDC_FIELD USING FNAM FVAL.
      IF FVAL <> NODATA.
        CLEAR BDCDATA.
        BDCDATA-FNAM = FNAM.
        BDCDATA-FVAL = FVAL.
        APPEND BDCDATA.
      ENDIF.
    ENDFORM.

  • [질문]request 나 session의 setAttribute 메소드가 왜 안되죠?

    * 질문한 사람 : skwoo
    * 질문 등록일 : 2001-07-18 00:41:04
    * 조회 : 45094
    * 답변 : 4건 (gaku98, mychin, intermin)
    -- 질문 내용 --
    환경 : win2000 + oracle 8.1.7
    session.setAttribute("test", "HaHa") 와 같은 문장을 테스트해보면
    jserv.log 로그화일에 다음 로그가 생깁니다.
    [18/07/2001 00:23:51:577 GMT+09:00] java.lang.NoSuchMethodError: javax.servlet.http.HttpSession: method setAttribute(Ljava/lang/String;Ljava/lang/Object;)V not found
    at org.apache.jserv.JServConnection.processRequest(JServConnection.java)
    at org.apache.jserv.JServConnection.run(JServConnection.java)
    at java.lang.Thread.run(Thread.java:479)
    -- 답변 내용 --
    1. gaku98 님의 답변
    setAttribute()의
    첫번째 인자로 String, 두번째 인자로 Object 타입을
    입력해야 하는 게 아닌가 합니다.
    Servlet API 2.3의 내용입니다.
    public void setAttribute(java.lang.String name,
    java.lang.Object value)
    다음은 예제 입니다. 참고하세요.
    <%
    ShoppingCart cart = (ShoppingCart)session.
    getAttribute("cart");
    // If the user has no cart, create a new one
    if (cart == null) {
    cart = new ShoppingCart();
    session.setAttribute("cart", cart);
    %>
    2. gaku98 님의 답변
    제가 착각을 했네요.
    위의 사용법은 잘못된 것이 없구요.
    아마도 javax 패키지가 패스에 제대로 잡히지 않아서 인 것 같습니다.
    3. mychin 님의 답변
    제 생각엔 servlet API버전이 낮아서 그런것 같습니다.
    session.setAttribute()를
    session.putValue()로 바꿔서 사용해 보시면
    될것 같습니다.
    정 setAttribute를 사용하고 싶으시면 servlet 버전을
    업데이트하시기 바랍니다.
    4. intermin 님의 답변
    Httpsession session=req.getsession(true);
    session.setAttribute(변수명, 값);
    위 값이 제대로 해주셨는지 확인해보세여..

  • Call stateless session bean EJB 2.0 from Webdynpro Java UI

    Hello,
    Can someone please tell me asto how to call a stateless session bean EJB 2.0 from Webdynpro Java UI?
    The NWDS version is 7.0.
    Thanks and Regards,
    Arya

    Hi Aryadipta
    Please check this pdfs
    https://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/b00917dc-ead4-2910-3ebb-b0a63e49ef10&overridelayout=true
    Steps for calling stateless session bean in Webdynpro java
    Go to NWDS -> open perspective ->j2ee
    select EJB Module Project ->create a project with name
    Open the Project -->RC on ejb-jar.xml -> Select new --> EJB
    Give name to EJB Bean (First letter should be in capital letters)
    select the type of bean as Stateless session bean and give the package name to store that EJB bean.
    After that Expand ejb-jar.xml and then select the <projectEJB> 
    Double click on this on method  tab double click you will get business method where we will create the methods for business logic
    Double click on projectEJB and then RC on bean tab and write required business logic in bean window as follows(based on requirement we will design a business logic).
    After writing the business logic go to project -> rebuild
    Till now we have created one EJB jar file
    then go to File-->Enterprise Application Project -->create a project (projectEAR)
    After creating a project click on next-> here we will have ear projects and then we select specific project required for our application.(here select projectEJB)
    After that Calculate EAR project will be available on j2ee explorer.
    Right click on <Bean> here
    select New->Web Service->give a name to webservice and select Default configuration type as simple SOAP
    -->click next -> Finish.
    That webservice and related are created in ejb-jar.xml .
    Expand the ejb-jar.xml.and double click on < webservice>
    RC ProjectEJB -> Build EJB Archive RC on CalculateEAR ->Build applicationarchive.
    Expand the projectEAR->RC on CalculateEAR.ear->Deploy to J2EE Engine
    Double click on calculateEAR.ear ->Webservice navigator tab ->we eill servers expand the node
    select the specific WebService  
    Here we test the webservice by click on Test and test it.
    After that go to Web dynpro perspective ->create one webdynpro Project and one component
    RC on model> Select import Web Service model(last)>give model name and package
    and select radio button as local file system or URL
    Go to WSnavigator->copy the WSDL path and paste it in model WSDL path and click on finish.
    from here onwards steps are same as that adaptive RFC model
    Hope it helps
    Thanks
    Tulasi Palnati
    Edited by: Tulasi Palnati on Aug 26, 2009 12:15 PM
    Edited by: Tulasi Palnati on Aug 26, 2009 12:43 PM

Maybe you are looking for