How to Use Weblogic6.1 JAAS Sample in Servlet???

Hi there,
I am now developing JAAS security service based on weblogic. Here is the problem I met with:
1. There is no problem when invoking JAAS sample from application.
But Subject.doAs() is denied when moving the application to servlet.
2. It is said that when invoking JAAS from servlet,
an authenticated subject will be returned using:
Subject subjectTest = loginContext.getSubject();
How can I store the subject into the session and be called later?
3. getUserPrincipal(), isUserInRole() are two important
methods in authenticaion on web services.
How is the user principal and role stored in the session?
4. Where can I find some tutorials on invoking JAAS service from servlet?
Thanks.
============================================================
This is my source code
package examples.security.jaas;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.io.*;
import java.util.*;
import javax.security.auth.Subject;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.TextOutputCallback;
import javax.security.auth.callback.TextInputCallback;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
import javax.security.auth.login.FailedLoginException;
import javax.security.auth.login.AccountExpiredException;
import javax.security.auth.login.CredentialExpiredException;
public class SampleServlet extends HttpServlet
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
doPost(req, res);
System.out.println("1\n");
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
HttpSession session = req.getSession(true);
res.setContentType("text/html");
PrintWriter out = res.getWriter();
System.out.println("2\n");
String username = req.getParameter("username");
String password = req.getParameter("password");
String url = req.getParameter("url");
LoginContext loginContext = null;
Context ctx = null;
try
// Set server url for SampleLoginModule
Properties property = new Properties(System.getProperties());
property.put("weblogic.security.jaas.ServerURL", "http://localhost:7001");
System.setProperties(property);
property = new Properties(System.getProperties());
property.put("weblogic.security.SSL.ignoredHostnameVerification", "TRUE");
System.setProperties(property);
// Set configuration class name to load SampleConfiguration
property = new Properties(System.getProperties());
property.put("weblogic.security.jaas.Configuration", "examples.security.jaas.SampleConfig");
System.setProperties(property);
// Set configuration file name to load sample configuration policy file
property = new Properties(System.getProperties());
property.put("weblogic.security.jaas.Policy", "Sample.policy");
System.setProperties(property);
// Create LoginContext; specify username/password login module
loginContext = new LoginContext("SamplePolicy", new MyCallbackHandler());
catch(SecurityException se)
se.printStackTrace();
System.exit(-1);
catch(LoginException le)
le.printStackTrace();
System.exit(-1);
System.out.println("SampleServlet:" + username + "\n");
// Attempt authentication
try
// If we return without an exception, authentication succeeded
loginContext.login();
catch(FailedLoginException fle)
out.println("Authentication Failed, " + fle.getMessage());
System.exit(-1);
catch(AccountExpiredException aee)
out.println("Authentication Failed: Account Expired");
System.exit(-1);
catch(CredentialExpiredException cee)
out.println("Authentication Failed: Credentials Expired");
System.exit(-1);
catch(Exception e)
out.println("Authentication Failed: Unexpected Exception, " + e.getMessage());
e.printStackTrace();
System.exit(-1);
// Retrieve authenticated subject, perform SampleAction as Subject
out.println("Authentication succeeded " );
System.out.println("===============start to trace333\n");
Subject subject = loginContext.getSubject();
System.out.println("Subject:"+subject.toString()+"\n");
System.out.println("Subject.getclass:" + subject.getClass().getName());
SampleAction sampleAction = new SampleAction();
Subject.doAs(subject, sampleAction);
System.out.println("4\n");
// System.exit(0);
========================================================
void doPost(
HttpServletRequest req,
HttpServletResponse resp) {
Principal p =
req.getUserPrincipal();
auditCall(p.getName());
if (req.isUserInRole(
"ManagersRole")) {
// Do some Manager stuff
} else if
(ctx.isUserInRole(
"SalesRole")) {
// Do some Sales stuff
I'll describe where JAAS fits in to the web app model but please note that some of this should be automatically handled by your Servlet container.
Servlet engine (or your MVC servlet controller) receives a request for a protected resource.
It then checks for the existence of an "authenticated" token in the HttpSession.
If that token doesn't exist then it forwards the user to the login page.
The user fills in the form, and the login servlet receives the username and password at which point the JAAS Login Module is called with two callback objects: one that returns the username and one that returns the password.
The JAAS Module checks to see if the credentials are valid, if not, it throws an authentication exception.
Once control is returned to the Login Servlet, the Login Servlet would add the authenticated "Subject" to the HttpSession and if necessary, an authentication "token".
So, JAAS is really only called ONCE, not for every web request, and it's called
by the "logical" Login Servlet AFTER the user submits their login information.
JAAS is not used to check for whether the user is authenticated already or not.
the weblogic 6.1 server side exception
username: joeuser
password: joepass
<May 25, 2002 11:05:20 PM PDT> <Error> <HTTP> <[WebAppServletContext(2169486,exa
mplesWebApp,/examplesWebApp)] Servlet failed with Exception
java.lang.SecurityException: Attempting Privileged Action With Unauthenticated S
ubject
at javax.security.auth.Subject.doAs(Subject.java:74)
at examples.security.jaas.SampleClient.startWeb(SampleClient.java:200)
at jsp_servlet.__poc1._jspService(__poc1.java:92)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:265)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:200)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:2495)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2204)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>

If anyone of you, has got any answers related to the above mentioned problem, Post it here, Will folks from SUN respond to this at any time.
Regards
Jayendran

Similar Messages

  • How to use an IFrame with my servlet?

    Hello, my question is this (basically, I'm building a "social" application for one of the social networks out there,
    but I'm using a java servlet as my back-end server, though I don't know if it matters to my question) -
    I want to insert an iframe to my application, but I didn't find good material on how to use this, and what to add to my servlet
    for completing the communication with the iframe - can anyone give an example maybe, or a link to a good piece of code.
    Basically, what I want for my application is to simply allow a user to record a voice message, and save it somewhere,
    and for that I need to use a java library, and this is why I thought building it with an iframe that will directly communicate with my java servlet. - IS THIS A GOOD IDEA?
    thanks :)
    Kogan.

    IFrame is just a HTML element. You normally embed HTML elements in a JSP file. How to use an IFrame is covered by every average HTML tutorial.
    What's your actual problem?

  • How to use a javaBean in a servlet without FORMS...

    Hi,
    I would like to use a javaBean in a Servlet.
    I know how you can do this with the code
    HttpSession session = request.getSession();
    in your servlet.
    However, by using this code you have to call the servlet by a FORM. Is it possible to call the servlet (which calls the javaBean) in your JSP file without a FORM?
    Greetings
    Tigi

    Thanks Anthony,
    I'm working with Tigi on the same project and now I can tell you that the problem is solved.
    request.getRequestDisptacher("/myServlet");hehe, you switched the 't' and the 'a'
    <%@ include file="/myServlet" %>this is the one we use :)
    But what is the difference between the first one and the last one? Now We are using the last one because that's the shortest :) not a pretty good reason huh :)
    cheers,
    Soep

  • How to use wsus api samples

    hi
    i want to use ComplianceReport from wsus api. what shall i do?
    please guide me
    best regards

    I'm confused... are you looking for instruction on how to use Visual Basic?
    Have you read the
    API Samples and Tools Readme?
    Having asked that, a couple of items of significant note:
    You've apparently downloaded the *WSUS v2* Samples and Tools (not sure why it's still linked, but it is). What you'll need to download is the
    *WSUS v3* Samples and Tools.
    The "Compliance Report" you are trying to use is no longer included in the Samples and Tools package because it's now incorporated into the product itself. Have you reviewed the IN-CONSOLE reports yet? Specifically the "...For Approved Updates"
    reports.
    Lawrence Garvin, M.S., MCSA, MCITP:EA, MCDBA
    SolarWinds Head Geek
    Microsoft MVP - Software Packaging, Deployment & Servicing (2005-2014)
    My MVP Profile: http://mvp.microsoft.com/en-us/mvp/Lawrence%20R%20Garvin-32101
    http://www.solarwinds.com/gotmicrosoft
    The views expressed on this post are mine and do not necessarily reflect the views of SolarWinds.

  • How to use connection pool in jsp/servlet ?

    I found I can "lookup" it in either java beans/servlets/JSP using JNDI. why?
    what is the best practice to use it in a jsp/servlet web app considering JNDI lookuping expensive?
    Thanks!
    Bo
    Edited by: BobXu on Nov 17, 2008 2:27 PM
    Edited by: BobXu on Nov 17, 2008 2:32 PM

    Huh?
    You can lookup a JNDI resource from anywhere in java code you want to. As long as you have a repository set up to search on :-)
    Of course whether that resource is available or not is a different matter. If you let the server set up the JNDI resource for you, then you can't run it standalone outside the server without something else setting the same thing up :-)
    So its not so much a limitation of beans, but just the environment you run the code in.
    Best practice? Don't write sql queries in JSP pages :-)
    For the rest you might consider the DAO pattern. Or ignore SQL altogether and let hibernate do the work there for you.
    Cheers,
    evnafets

  • How to use the Javabeans in the servlets

    I want to use the beans in the servlets ..
    Please help me out with some good examples...
    and the resources where I can get the related hints

    For visual beans, check out jsp:plugin
    This will convert you bean to an applet.
    For non-visual beans, check out jsp:useBean

  • How to use RMI objects in a servlet

    Hi,
    I have just run the example RMI program in the java tutorial in my linux pc. Also I have another method to just echo a string back. It works fine when calling from command line.
    Now I want to write a servlet that get a string when POSTed and call the RMI objects echo method and display the returned string.
    I use Tomcat-5.0 which is installed in /usr/local. I moved the remote object interface jar to the common/lib folder and import the interface in my Servlet. I use the following statements inside the servlet to get the RMI object reference.
                Registry registry = LocateRegistry.getRegistry("localhost");
                Rser comp = (Rser) registry.lookup("rmiser");When i use this in my servlet the tomcat stops working.
    Also I don't know how to specify the code base and security policy which I use in command prompt when calling RMI object.
    Pls suggest me what to do and also specify any resources that explain this task step by step.
    Thanks.

    restarted the system and caught the following exception while calling the servlet.
    Apr 30, 2009 12:24:15 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 3861 ms
    java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)
         at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
         at java.security.AccessController.checkPermission(AccessController.java:546)
         at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
         at java.lang.SecurityManager.checkConnect(SecurityManager.java:1034)
         at java.net.Socket.connect(Socket.java:513)
         at java.net.Socket.connect(Socket.java:469)
         at java.net.Socket.<init>(Socket.java:366)
         at java.net.Socket.<init>(Socket.java:180)
         at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
         at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
         at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
         at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
         at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
         at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
         at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
         at RequestParamExample1.doGet(RequestParamExample1.java:94)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at filters.ExampleFilter.doFilter(ExampleFilter.java:101)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
         at java.lang.Thread.run(Thread.java:619)
    Apr 30, 2009 12:25:19 PM org.apache.coyote.tomcat5.CoyoteAdapter service
    SEVERE: An exception or error occurred in the container during the request processing
    java.security.AccessControlException: access denied (java.lang.RuntimePermission setContextClassLoader)
         at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
         at java.security.AccessController.checkPermission(AccessController.java:546)
         at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
         at java.lang.Thread.setContextClassLoader(Thread.java:1351)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
         at java.lang.Thread.run(Thread.java:619)
    Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" java.security.AccessControlException: access denied (java.lang.RuntimePermission setContextClassLoader)
         at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
         at java.security.AccessController.checkPermission(AccessController.java:546)
         at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
         at java.lang.Thread.setContextClassLoader(Thread.java:1351)
         at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1623)
         at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1608)
         at java.lang.Thread.run(Thread.java:619)
    Hope u can find it now.
    the line
    at RequestParamExample1.doGet(RequestParamExample1.java:94)
    is the file I am editing and using to call RMI.
    Edited by: itsraja on Apr 30, 2009 12:06 AM

  • How to use jdb for debugging a servlet?

    I'm using Apache/JServ with jdk 1.4 (via Textpad on win2K SP 3).
    The 'gospel' I'm trying to follow is:
    'Start the server manually and record the password for remote debugging
    (this is displayed on the console).'
    'Start the Java debugger:'
    'jdb -host your_host -password the_password'
    'You should be able to debug your Java classes now using the jdb
    command.'
    My problem is that I can't find the password from Apache.
    I normally start/restart apache as a windows Service.
    If I start it from DOS I get:
    'C:\orant9i\Apache\Apache>apache -k start'
    'Oracle HTTP Server Powered by Apache/1.3.12 (Win32) ApacheJServ/1.1
    mod_ssl/2.6.4 OpenSSL/0.9.5a mod_perl/1.24 running...'
    I've searched the log, conf & property files but can't find any password.
    I've also searched the Apache website for 'jdb' without luck.
    I've printed out (and read!) the 'Using Apache with MS Windows' manual.
    I did a Google:
    --Someone suggested starting Apache using using the -X flag, but I don't
    seem to have this option.
    --Someone else suggested changing jvm12.conf, but I don't have one.
    I have tried the following, just-in-case I don't really need a password,
    but it doesn't tell me a lot, and I would appreciate some help:
    JDB -sourcepath E:\javaPackages org.apache.jserv.JServServletManager
    C:\orant9i\Apache\Apache>JDB org.apache.jserv.JServServletManager
    Initializing jdb ...
    > run
    run org.apache.jserv.JServServletManager
    Set uncaught java.lang.Throwable
    Set deferred uncaught java.lang.Throwable
    >
    VM Started:
    Exception occurred: java.lang.ClassNotFoundException (uncaught)"thread=main", java.net.URLClassLoader$1.run(), line=199 bci=72
    main[1] list
    Source file not found: URLClassLoader.java
    main[1]
    Thanks,
    Peter.
    Posted to alt.apache.configuration, comp.lang.java, http://groups.yahoo.com/group/win-apache and
    comp.infosystems.www.servers.misc with no response

    Hello
    You wrote:
    I added the following to jserv.properties:
    wrapper.bin.parameters=-Xdebug
    wrapper.bin.parameters=-Xrunjdwp:transport=dt_socket,address=2930,suspend=n,server=y
    and it ran the servlet okay.Fine so far. This means your debugee VM is started and running. The "suspend=n" means it
    will start running without waiting for a debugger to attach... so you can attach later whenever you
    decide to debug. Note that 'later' could be weeks later, or possibly never.
    Now: Time to attach jdb to the victim/debugee process you started above.
    You wrote:
    But I get the following when I try to start jdb:
    jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=2930 org.apache.jserv.JServServletManager
    gives:
    Cannot specify command line with connector:
    com.sun.jdi.SocketAttach:hostname=localhost,port=2930,
    and
    jdb -attach localhost:2930 org.apache.jserv.JServServletManager
    gives:
    Cannot specify command line with connector: com.sun.jdi.SharedMemoryAttach:name=localhost:2930,The problem here is that you are trying to supply too much information to jdb.
    When you are using the attach connectors, all you need to supply is the
    host name and socket (for the socket connectors), or the name of the shared memory
    area (for the shared memory connector). The connectors you tried above are throwing
    an error because you are trying to supply something extra (the class name).
    When doing an attach, the debugee VM is already launched. The debugger will
    attach to it and inspect the classes loaded.
    If you are still running with the wrapper.bin.parameters you listed above,
    then all you need to connect with jdb is:
      jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=2930 You should get a jdb prompt, and you will be able to inspect the debugee
    VM by entering commands such as threads and classes. Typically
    the next thing would be to set some breakpoints (stop in package.class.method,
    or stop at package.class:line. Then restart the debugee with a resume.

  • How to use TreeByKeyTableColumn  (with sample code)

    Hi Guys,
                  Can anyone tell me How to bind data with TreeByKeyTableColumn ? (with sample code). Is it possible to add checkbox with TreeByKeyTableColumn? Kindly aware me further in this regards....
    Thanks,
    Ravin

    Hi
    Answering to following question
    How to bind data with TreeByKeyTableColumn
    Create the Context
    Click on the Context tab of the view. Create a node name it as "AIR_LINES". Set the Cardinality as 0...N. Make it a Singleton Node. Give a method name in supply function column by name "GENERATE_TREE".
    Then we will create attributes required for the tree column. We require 5 attributes
       1. Attribute which contains the current level of the node. Create an attribute called "NODE_LEVEL" of type STRING.
       2. Attribute which contains the parent level of the node. Create an attribute called "PARENT_LEVEL" of type STRING.
       3. Attribute which contains the contents of the node. Create an attribute called "NODE_CONTENT" of type STRING.
       4. Attribute which contains X or Space depending upon the node is expanded or not. Create an attribute called "EXPANDED" of type WDY_BOOLEAN.
       5. Attribute which contains X or Space depending upon the type of the node, whether the node is a branch or a leaf. Create an attribute called "IS_LEAF" of type WDY_BOOLEAN.
    Click on the layout tab of the view. Add UI element of type Table, give the name as 'Tree Table'. Bind the DATASOURCE property of the table to the AIR_LINES node of the view context.
    Give heading to the table as "Booking Details".
    Right click on table node crated and chose Insert Master Column.
    Name it as "TREE_NODE" and chose TreeByKeyTableColumn from the dropdown
    Bind the 4 properties with context attributes we have already created.
    Expanded -> Expanded.
    Is_leaf     -> Is_leaf.
    Parent_key -> Parent_level
    Row_key   -> Node_level
    Give heading to the tree node in the text field.
    Insert a cell editor in the tree column and chose the type as Text view.
    Bind the text property of the text view to the NODE_CONTENT attribute of the context.
    Similarly create a table column to display the second column i.e. Node type.
    Right click -> Insert table column -> Give the heading in the text property of the header (Node Type).
    Right click -> Insert Cell Editor -> Bind the text property to NODE_TYPE attribute of the context.
    Click on the Methods tab of the view. You will find the method of type supply function which we created during the creation of node. Double click and write the following code.
    METHOD generate_tree .
    Ideally this code must go to a method of a class which will return four internal tables
    start of Model code
    TYPES : BEGIN OF ty_scarr,        " Air line Table
             carrid TYPE s_carr_id,
            END OF ty_scarr.
    TYPES : BEGIN OF ty_spfli,        " Flight Connection Table
             carrid TYPE s_carr_id,
             connid TYPE s_conn_id,
            END OF ty_spfli.
    TYPES : BEGIN OF ty_sflight,      " Flight Table
             carrid TYPE s_carr_id,
             connid TYPE s_conn_id,
             fldate TYPE s_date,
            END OF ty_sflight.
    TYPES : BEGIN OF ty_sbook,        " Flight Booking Table
             carrid TYPE s_carr_id,
             connid TYPE s_conn_id,
             fldate TYPE s_date,
             bookid TYPE s_book_id,
            END OF ty_sbook.
    DATA : lt_scarr TYPE TABLE OF ty_scarr.
    DATA : lt_spfli TYPE TABLE OF ty_spfli.
    DATA : lt_sflight TYPE TABLE OF ty_sflight.
    DATA : lt_sbook TYPE TABLE OF ty_sbook.
    DATA : ls_scarr TYPE  ty_scarr.
    DATA : ls_spfli TYPE  ty_spfli.
    DATA : ls_sflight TYPE ty_sflight.
    DATA : ls_sbook TYPE  ty_sbook.
    SELECT carrid
      FROM scarr
      INTO TABLE lt_scarr
      UP TO 2 ROWS.
    IF lt_scarr[] IS NOT INITIAL.
      SELECT carrid connid
        FROM spfli
        INTO TABLE lt_spfli
        FOR ALL ENTRIES IN lt_scarr
        WHERE carrid EQ lt_scarr-carrid.
        IF lt_spfli[] IS NOT INITIAL.
          SELECT carrid connid fldate
            FROM sflight
            INTO TABLE lt_sflight
            FOR ALL ENTRIES IN lt_spfli
            WHERE carrid EQ lt_spfli-carrid
            AND connid EQ lt_spfli-connid.
    For an additional level of branching
           IF lt_spfli[] IS NOT INITIAL.
               SELECT carrid connid fldate bookid
                 FROM sbook
                 INTO TABLE lt_sbook
                 FOR ALL ENTRIES IN lt_sflight
                 WHERE carrid EQ lt_sflight-carrid
                 AND connid EQ lt_sflight-connid
                 AND fldate EQ lt_sflight-fldate.
           ENDIF.
        ENDIF.
    ENDIF.
    End of Model code
    Start of code for generation the tree
    data declaration
      DATA lt_table TYPE wd_this->elements_air_lines.
      DATA ls_table LIKE LINE OF lt_table.
      DATA lvl1_index TYPE string.
      DATA lvl2_index TYPE string.
      DATA lvl3_index TYPE string.
      DATA lvl4_index TYPE string.
    Level 1
    LOOP AT lt_scarr INTO ls_scarr.
      lvl1_index = sy-tabix.
      condense lvl1_index.
      create a row
        ls_table-node_level       = lvl1_index.     " 1 st level
        ls_table-parent_level     = ''.             " No parent
        ls_table-node_content     = ls_scarr-carrid.
        ls_table-node_type        = 'Air Line'.
        ls_table-is_leaf          = abap_false.
        INSERT ls_table INTO TABLE lt_table.
        clear ls_table.
    Level 2
    LOOP AT lt_spfli INTO ls_spfli.
      lvl2_index = sy-tabix.
      condense lvl2_index.
      create a row
        concatenate lvl1_index `.` lvl2_index into ls_table-node_level.
        ls_table-parent_level     = lvl1_index.     " Parent 1 st level
        ls_table-node_content     = ls_spfli-connid.
        ls_table-node_type        = 'Flight Connection'.
        ls_table-is_leaf          = abap_false.
        INSERT ls_table INTO TABLE lt_table.
        clear ls_table.
    Level 3
    LOOP AT lt_sflight INTO ls_sflight.
      lvl3_index = sy-tabix.
      condense lvl3_index.
      create a row
        concatenate lvl1_index `.` lvl2_index `.` lvl3_index into ls_table-node_level.
        concatenate lvl1_index `.` lvl2_index into ls_table-parent_level.
        ls_table-node_content     = ls_sflight-fldate.
        ls_table-node_type        = 'Flight'.
        ls_table-is_leaf          = abap_true.
        INSERT ls_table INTO TABLE lt_table.
        clear ls_table.
    If you want an additional level it can be programmed like this
    Level 4
    *LOOP AT lt_sbook INTO ls_sbook.
    lvl4_index = sy-tabix.
    condense lvl4_index.
      create a row
       concatenate lvl1_index `.` lvl2_index `.` lvl3_index `.` lvl4_index into ls_table-node_level.
       concatenate lvl1_index `.` lvl2_index `.` lvl3_index into ls_table-parent_level.
       ls_table-node_content     = ls_sbook-bookid.
       ls_table-node_type        = 'Booking'.
       ls_table-is_leaf          = abap_true.      " as its the final level in our hier archy
       INSERT ls_table INTO TABLE lt_table.
    ENDLOOP.
    ENDLOOP.
    ENDLOOP.
    ENDLOOP.
    bind all the elements
      node->bind_table(
        new_items            =  lt_table
        set_initial_elements = abap_true ).
    ENDMETHOD.

  • How to use compiled LibPng?

    How to use compiled LibPng sample? I have compiled it (lib png) now I want to use it with bitmap data. Can any one please share some simple AS code for USING compiled lib png? Pleeease... I neew help...

    http://search.java.sun.com/search/java/index.jsp?qp=&nh=10&qt=%2BDelphi++%2Bdll&col=javaforums

  • How to compile and run a Java servlet using the BEA weblogic server

              Hi,
              Could you help me out as to how to compile a servlet using Web Logic server.I have written a Servlet program and have also set up the environment in the "c:\bea\wlserver6.0\config\examples" folder by giving the command setExamplesEnv.cmd.
              I have stored my GreetingServlet.java file in "c:\bea\wlserver6.0\samples\examples\servlets" folder.
              How do I compile my servlet now?
              Vid
              

    Hello,
    1. The .form file was used by Netbean's GUI builder to create the .java and is not needed for compilation.
    2..../src # javac -classpath "..." mytool/*.java
    I guess the package mytool was not coped with.
    Alternatively it is worth to use the ant build tool also used by Netbeans.
    Then you can make a jar from the class files, indicate in the manifest.mf file:
    1. the main class
    2. the library jars

  • How to use the LAN NetStream for peer transmission, please help, write a sample code

    How to use the LAN NetStream for peer transmission, please help, write a sample code

    No reply, I reply, Oh

  • How to use my connection pool in multiple servlets?

    I now have a functioning connection pool using these lines in a servlet:
    private Connection getConnection(String lookup) throws NamingException, SQLException {
    Context context = new InitialContext();
    DataSource ds = (DataSource)context.lookup(lookup);
    Connection ocon = ds.getConnection();
    context.close();
    return ocon;
    } // private Connection getConnection(String lookup) throws NamingException, SQLException {
    ========================
    If I want to create additional servlets in the same web app which query the same database,
    do I need to repeat this block of code in every servlet, or can I just put it in one servlet
    and have other servlets access it in some way to get a connection? Should I change the code
    above from a "private" Connection to a "public" Connection?
    An example servlet is shown below. To put my question another way: If I want to
    create a second servlet with a different set of queries, would I just make a copy of the first
    servlet and then change only the queries, or is there a more efficient way to have multiple
    servlets get connections from the pool?
    Any suggestions are greatly appreciated.
    Thank you.
    Logan
    ************************************servlet example**********************************
    package CraigsClasses;
    import javax.servlet.*;
    import javax.servlet.jsp.*;
    import java.net.*;
    import java.util.*;
    import java.io.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.util.Date;
    import java.text.*;
    import javax.naming.*;
    import javax.sql.DataSource;
    public class CraigsMain extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    private Connection getConnection(String lookup) throws NamingException, SQLException {
    Context context = new InitialContext();
    DataSource ds = (DataSource)context.lookup(lookup);
    Connection ocon = ds.getConnection();
    context.close();
    return ocon;
    } // private Connection getConnection(String lookup) throws NamingException, SQLException {
    // Process the http Get request
    public void doGet(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException {
    try {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String sql = "select formtitle from checkboxforms where cbformid = 157";
    // error occurs at this line
    Connection ocon = getConnection("java:comp/env/jdbc/CraigsList");
    PreparedStatement pStmt = ocon.prepareStatement(sql);
    ResultSet rs1 = pStmt.executeQuery();
    rs1.next();
    out.println("<br>" + rs1.getString(1));
    rs1.close();
    pStmt.close();
    ocon.close();
    } catch(SQLException sqle) {
    System.err.println("sql exception error: " + sqle);
    } catch(NamingException ne) {
    System.err.println("naming exception error: " + ne);
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    doGet(request, response);
    =======================================================================

    sjasja, Thank you for the reply. What you are suggesting is exactly what I have been looking for. But I'm pretty weak on how to make this separate con pool servlet work. My first attempt is shown below. It doesn't compile this line, which is obviously wrong:
    public static Connection getConnection(String lookup) throws NamingException, SQLException {
    Could you please help me with this servlet code? Thanks.
    package CraigsClasses;
    import javax.servlet.*;
    import javax.servlet.jsp.*;
    import java.net.*;
    import java.io.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import javax.naming.*;
    import javax.sql.DataSource;
    public class ConPoolInit extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    try {
    public static Connection getConnection(String lookup) throws NamingException, SQLException {
    Context context = new InitialContext();
    DataSource ds = (DataSource)context.lookup(lookup);
    Connection ocon = ds.getConnection();
    context.close();
    return ocon;
    } // private Connection getConnection(String lookup) throws NamingException, SQLException {
    } catch(SQLException sqle) {
    System.err.println("sql exception error: " + sqle);
    } catch(NamingException ne) {
    System.err.println("naming exception error: " + ne);
    =======================================

  • I am a high school teacher.  My district purchased the entire CC Suite.  Where can I find a tutorial in book form to learn how to use your products?  Do you all provide free book samples to teachers?

    I am a high school teacher.  My district purchased the entire CC Suite.  Where can I find a tutorial in book form to learn how to use your products?  Do you all provide free book samples to teachers?

    Good day!
    This is a user to user Forum, so you are not really addressing Adobe here, even though some Adobe employees thankfully have been dropping by. (edit: Actually they are more likely to frequent the regular Photoshop Forum.)
    Regards,
    Pfaffenbichler

  • How do i ensure my sampling rate is a constant and correct (@250Hz) when using AI Sample Channel vi

    I am running a VI that samples 2 channels using the AI Sample Channel vi within a for loop (executing equal to the number of samples i require), i then calculate the difference between the channels. Within the for loop i use a chart to displays this difference in realtime.
    On exiting the loop the data is converted to an array, which in turn i then convert to a waveform (using dT as 0.01 as an arbitary solution at the moment). The waveform is then compared to limits using the limit specs and limit testing vi's.
    There is also other code displaying graphs from the previous iterations of the VI.
    My question is how do i control the aquisition rat
    e so that i know that the AI Sample Channel vi is sampling my data at a set rate (250Hz)?
    I have tried to use some of the hardware timed exaples supplied by NI to no avail. They can't give me the single point output required within the initial for loop for the real-time display.
    Any solutions welcome!!

    How about buffered acquisition? You can let your DAQCard acquire the number of samples you require instead of doing it with a FOR loop. Using a FOR loop means that you are software timed, which may as well be untimed since it's about as deterministic as the weather in Florida.
    Look for the "Acquire N Scans.vi" example.
    If you want to do this the RIGHT way, use continuous acquisition. Start your acquisition and keep doing AI Read in a loop. Also include your porcessing and display functions in the loop. Just make sure your loop runs fast enough to keep up with your acquisition. At 250 Hz, you should have no problem.
    Dan Press
    www.primetest.com

Maybe you are looking for

  • Business Model and Mapping layer

    I am trying to create a logical dimension table by dragging the corresponding table from the physical layer. However, in the business model layer it shows up with a yellow icon indicating it is a logical fact table. Please help me how I create a logi

  • Forms: How to add large text without getting wrapped

    hi Waveset/Sun IDM folks, I need to add a large text to the form via a Field at the bottom of the Form. So using Title and SubTitle form properties is not an option. When I use Label/Text/TextArea type of Fiels, I see that the text is getting wrapped

  • Exporting to Quicktime - quality vs. size

    Ok here is my dilemna. I want the best possible quality at about 1-1.5gb per hour worth of video. I also need to be able to re-import this video file into imovie for changes in the future. What is my best option?

  • Error message when I try to copy and paste using mouse

    I am taking college classes online. When I try to copy and paste something using the right mouse button I keep getting error messages that something is blocked on my browser, and cannot copy and paste. When I use ctrl A ctrl C ctrl V everything works

  • MOVED: Help!! Where can i get WD SATA Drivers for winXP-64 Bit

    This topic has been moved to Operating Systems. Help!! Where can i get WD SATA Drivers for winXP-64 Bit