How to use session bean connect to socket server?

Can any body provice an example for this?
Thank you.

Hi,
You have to catpture the "set-cookie" header from the response which you got in the first request. The same "set-cookie" value has to be set in the subsequent requests' header. Please see the below code snippet to collect the "set-cookie" and set the cookie in the subsequest requests.
//how to Collect the "set-cookie" from the response
if (urlConnection != null)
for (int i = 1;(key = urlConnection.getHeaderFieldKey(i)) != null; i++)
System.out.println(urlConnection1.getHeaderFieldKey(i) + ": " + urlConnection.getHeaderField(key));
if (key.equalsIgnoreCase("set-cookie"))
String cookiValue = urlConnection1.getHeaderField(key);
//How to set the cookie value in the subsequent requests
urlConnection2.setRequestProperty("Cookie", cookiValue);
Good luck.

Similar Messages

  • How to use Java to connect to LDAP server

    We have a requirement is to get LDAP service through XI.
    Scenario is SAP <-> XI <-> LDAP
    It seems there is not a LDAP adapter for XI now, so, is it possible to embed a Java program to access LDAP server? We already have a program like this:
    SAP <-> Java (through JCo) <-> LDAP

    Thanks, I checked this document. Does it mean we still need to run a standalone java application?
    SAP -> RFC Adapter -> XI -> Java Proxy -> Java Application -> LDAP Server
    Is it possible just build the java application to a jar in XI ? The reason is, if we still need to run a Java application, and it can connect to SAP directly (through JCo). I cannot find any benefit to migrate to XI.
    Our wish is
    SAP -> RFC Adapter -> XI -> Java Proxy -> LDAP Server

  • Is it possible to connect database using session bean

    Dear all,
    Is it possible to connect database using session bean without using entity beans like cmp,bmp.
    if ur answer is yes, then pls tell me where to put the select statement and transaction attribute like(6 types).
    if u have sample code, then it is good for me.
    Hope I will get answer.

    Sure it is.
    Try something like this (and maybe get a book on JDBC):
    String name;
    try {
         InitialContext ic = new InitialContext();
         DataSource ds = (DataSource) ic.lookup(Constants.MY_DATASOURCE);
         Connection connection = ds.getConnection();
         String sql = "SELECT * FROM TABLE";
         PreparedStatement statement = connection.prepareStatement(sql);
         ResultSet rs = statement.executeQuery();
         while (rs.next()) {
              name = rs.getString("NAME");
         if (rs != null)
              rs.close();
         if (statement != null)
              statement.close();
         if (connection != null)
              connection.close();
    catch (NamingException e) {
         // Can't get JDBC datasource
         // ... do something with this exception
    catch (SQLException e) {
         // SQL exception from getter
         // .... do seomthing with this one too
    }

  • Can I connect with Database using Session Bean

    Hi,
    I am new to EJB. I have small doubt.
    can I connect with Database using Session Bean.
    Regards,
    Murali.

    Double post of http://forum.java.sun.com/thread.jspa?threadID=687239&tstart=0

  • Session bean connecting a data source

    Hi there,
    I'm trying to make a session bean connect to a DataSource used by my Entity Beans. I'm using JBuilder5 and Borland Application Server.
    Here is the code in my SessionBean:
    InitialContext ic = new InitialContext();
    DataSource datasource = (DataSource)ic.lookup("java:comp/env/jdbc/DataSource");
    System.out.println("Datasource=" + datasource.toString());
    Connection dbConnection = datasource.getConnection();
    Statement stmt = dbConnection.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT ID FROM PUBLICATION");
    rs.next();
    System.out.println(rs.getString("ID"));
    I have already put a reference to this DataSource in the Deployment Descriptor but I get the following error message:
    [Microsoft][ODBC Driver Manager] Data
    source name not found and no default driver specified
    But with the CMP Entity Beans the DataSource works.
    I would appreciatte any help. Thanks in advance.
    Nei.

    Hi GHz,
    I have a method in my Session bean QuerySessionBean called showData() that have the code I typed before. Sorry, but what do tou mean when you say that I must excute the query inside the session bean? I'm testing the method in a client using queryHome.showData().
    Thanks for answering,
    Nei

  • How to use session in webservice?

    In C#, can use session variable in a webservice object.
    How to use session in Java webservice?
    Who can give me a example?
    Thanks a lot

    Did I use session in a wrong way?No, you are using the session correctly. The code looks fine.
    Check
    - your spelling of the attribute names - obviously they must match
    - the ids of the sessions you get both times: session.getId(). If they have different ids, then most probably the session is being lost somewhere.
    There are a number of reasons to lose a session. If you close the browser, invalidate the session in code, or lose the cookie recording the id. This happens when you change from https to http, so a session can be lost that way.
    The session is normally maintained by session cookies. If you close your browser you lose the cookie. If you have disabled cookies on your machine then it also might not work.
    In cases such as that you should be using the method response.encodeURL() to maintain the session for you in any hyperlinks you produce. Struts normally handles that for you though if necessary.
    Hope this helps,
    evnafets

  • How to use session object in jsp

    hi all
    marry christmas
    can anyone plz tell me how to use session obect in jsp
    rachna
    Message was edited by:
    rachna_arora82

    hi rachna,
    JSP has a default(implicit) session object...... use the getSession(true) method on the session object and then going u can either get or set attributes depending on the requirement
    That was in general and now with the issue u have got..... what u can do is that the u can create session for every user who logs in and when he/she tries to login again then u can probably check for the existing session object in the JSP and perform the logic as required..... any clarifications plzzzzzzz let me know
    Thanks n Regards
    Naveen M
    Message was edited by:
    Novice_inJAVA
    Message was edited by:
    Novice_inJAVA

  • How to use Java Beans In JSTL?

    Hi
    I want to know how to use Java bean in JSTL
    please explain this with giving any one example.
    Thanks-
    Swapneel

    A bean is obtain by <jsp:useBean> tag nd once bean is obtained we can get its property by using getProperty tag.

  • How do I make a connection to SQL Server Express using SQL Developer 1.5.3?

    How do I make a connection to SQL Server Express using SQL Developer 1.5.3, if it's possible at all?
    Also, I received a SQL Server dump file of some sort. Is there any way to read this file in SQL Developer and migrate the db to Oracle? Unfortunately I don't have raw DDL and DML for this database--just some sort of a binary dump file from SQL Server.
    Thanks.
    Dana

    Are you using SQL Developer 1.5.3 or 1.5.4?
    If using an older version (i.e. 1.5.3), then you'll have to add a DLL to your environment. This is [ntlauth.dll].
    If you don't find this DLL in your SQL Developer directory, then obtain the JDBC SQL SERVER Pluggin (jtds-1.2.2-dist.zip) from:
    http://sourceforge.net/project/showfiles.php?group_id=33291&package_id=25350
    Copy the ntlmauth.dll in the ...\\...\ide\lib directory (no need to register it).
    Note: this approach should work if using DQL Developer 1.5.3 and SQL Server Express 2008
    Regards,
    M. R.

  • Using Session Beans on a read only database

    Hi,
    i am working on a weblogic 6.1 server and have to access a read only database
    using session beans. The transaction attributes of all session beans (we are using
    no entity beans) are set to NOT_SUPPORTED but every time a method is accessed
    an error message is thrown
    BEGIN TRANS in read only database .....
    Is there a way to avoid this?
    Regards
    Edmund

    I guess it is NotSupported. If not try Never.
    --Jay   
    www.architectslobby.org
    An exclusive community for Enterprise Architects

  • How to used the internet connection adsl on my com...

    how to used the internet connection adsl on my computer by nokia n73 me
    i whant used the adsl connection in nokia n73 me by Bluetooth or cable
    and thank you

    Hi Theo,
    There are several ways to implement this using simple timing features of LabVIEW.  Two fairly simple methods are comparing system time stamps or using the Wait VI provided in the Timing palette.  The time stamp comparison requires a little bit more programming, but can be included in your main program loop.  To use the Wait function, you will probably need to construct a new loop parallel to your main loop.  I have attached screenshots of these two implementations.  Please let me know if you have any more questions.
    Donovan
    Attachments:
    WaitDelay[1].Png ‏5 KB
    TimeStampFalse.Png ‏11 KB
    TimeStampTrue.Png ‏11 KB

  • HT201205 how to use bluetooth to connect iphone to ipad???

    how to use bluetooth to connect iphone to ipad???

    what you do you expect them to be able to do with eachother ?
    you can transfer files or data between them unless you find some 3th party program which does that
    this is what ios devices support in terms of bluetooth profiles
    http://support.apple.com/kb/ht3647
    this is the full list of all bluetooth profiles (even your computer only support a fragtion of the list)
    http://en.wikipedia.org/wiki/Bluetooth

  • I want to use jdbc to connect MS SQL SERVER

    hi,
    I want to use jdbc to connect MS SQL SERVER,not the jdbc-odbc bridge.
    I download the driver from MS,deploy it,but when I connect the database such as:
    <%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");%>
    <%String sConnStr="jdbc:microsoft:sqlserver://computer2000:1433";%>
    <%Connection conn=DriverManager.getConnection(sConnStr,"sa","123");%>
    <%Statement stmt=conn.createStatement();%>
    but it said
    javax.servlet.ServletException: com.microsoft.jdbc.sqlserver.SQLServerDriver
    java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
    how can i work out this problem
    maybe my configure is wrong,please give me a successful sample configuration
    thanks a lot

    Hi,
    I am not sure where you have got the following code from
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    What happens here, is Java Runtime will search for the Class named:
    com.microsoft.jdbc.sqlserver.SQLServerDriver
    If this Class is not in the Runtime Classpath, it will throw the Error that you have got. Kindly get the proper driver as well as ensure that the Class is available in the Runtime Classpath.
    Thanks and regards,
    Pazhanikanthan. P

  • How to limited Media Encoder connect the media server?

    how to limited Media Encoder connect the media server?
    I have a adobe media server3 for liniux and  hava a live IP.
       I can  use the Media Encoder connenct the media server anywhere  when I use the live IP.
    I want to know how to limited Media Encoder connect the media server.
    thank you!

    You can use an authorization plugin, or you can use server side actionscript to validate credentials (as of FMS 3.0, you can use get variables in the RTMP URL)

  • How to find existing DAC connection to sql server

    How to find existing DAC connection in sql server  

    Hi RoyalM,
    Vishal has answered your initial question. If you have the connection issue. I suggest you elaborate the issue in a new thread.
    You can access DAC using SQLCMD from a command prompt. Or check the existing DAC connection in a command prompt:
    1. Open Command Prompt.
    2. Type: SQLCMD –S <servername\instance> -d master and press Enter.
    1> SELECT name,local_tcp_port FROM sys.dm_exec_connections ec join sys.endpoints e on (ec.endpoint_id=e.endpoint_id) WHERE e.name='Dedicated Admin Connection'
    2> go
    3. If it returns the result, it means there is an existing DAC connection. It also shows the port used by dedicated admin connection.
    Thanks.
    Tracy Cai
    TechNet Community Support

Maybe you are looking for

  • Automatic GL account pick for service PO

    When I raise PO with account assignment u2018 Ku2019 it ask cost center and pick the GL account automatically from OBYC table. But when I raise PO for service with item category u2018 D u2019 and account assignment u2018 k u2018 it picks different GL

  • Appworld doesn't work

    Hi I have a problem with my Blackberry, it's the Blackberry curve 9220. I bought it the last week.. When i try to go in to app world the telephone say that I have to update appworld, i click on "update" and the phone tries to go in the blackberry sit

  • TREX Installation Errors

    Hello I need help, I´m installing TREX in a separate host from portal, the installation does not finish and I recive the following error messages when the installation wizard is starting TREX_02 instance: ============== Error 1 FSL-06002 Error 1053 (

  • Can't open Finder or empty Trash

    I put 2 locked files into Trash.  Now I get a constant pop-up window "Restore Windows".  I cannot empty trash or open it to unlock the files.  I tried downloading the Trashit app but it goes to Finder which I cannot open.  Please Help.  Thx.

  • JavaScript within JSP

    Hi all !! I'm stuck up. Is there any way by which i can actually embed JavaScript within a JSP file that contains no JSP code. Actually it is file with .jsp extention but from within it holds only java script inside <script> tags. The prerequisite is