I Need Help to Access The Source Code From A Form to Know the Calculation Formula

Hi,
I Need Help to Access The Source Code From A Form to Know the Calculation Formula. The application is a windows form application that is linked to SQL Server 2008. In one of the application forms it generates an invoice and does some calculations. I just
need to know where behind that form is the code that's doing the calculations to generate the invoice, I just need to get into the formula that's doing these calculations.
Thank you so much.

Hi, 
Thanks for the reply. This is a view and [AmountDue] is supposed to be [CurrentDueAmount] + [PastDueAmount] - [PaidAmount]. The view is not calculating [PaidAmount] right . Below is the complete code of the view. Do you see anything wrong in the code ?
Thanks. 
SELECT     [isi].[InvoiceID], [ii].[DueDate], [SubInvoiceID] = [isi].[ID], [INV_FacilityID] = [if].[ID], [if].[FacilityID],
[iff].[FacilityFeeID], [LoanID] = NULL, [isi].[PortfolioID], [isi].[Portfolio], 
                      [PaymentType] = [isis_fee].[SectionType], [Name]
= [iff].[Name], [ReceivedAmount], [dates].[CurrentDueAmount], 
                      [PastDueAmount] = CASE WHEN ISNULL([ReceivedAmount],
0) > 0 THEN [pastdue].[PastDueFeeAmount] + ISNULL([ReceivedAmount], 0) 
                      WHEN ISNULL([ReceivedAmount], 0) 
                      < 0 THEN /* We bring past due to zero and
apply reset to current. */ CASE WHEN [pastdue].[PastDueFeeAmount] + ISNULL([ReceivedAmount], 0) 
                      < 0 THEN 0 ELSE [pastdue].[PastDueFeeAmount]
+ ISNULL([ReceivedAmount], 0) END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                      [pastdue].[PastDueFeeAmount] < 0 THEN 0 ELSE
[pastdue].[PastDueFeeAmount] END, [PaidAmount] = CASE WHEN ISNULL([ReceivedAmount], 0) 
                      < 0 THEN /* We bring past due to zero and
apply rest to current. */ CASE WHEN [pastdue].[PastDueFeeAmount] + ISNULL([ReceivedAmount], 0) 
                      < 0 THEN - ([pastdue].[PastDueFeeAmount]
+ ISNULL([ReceivedAmount], 0)) ELSE 0 END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                      [pastdue].[PastDueFeeAmount] < 0 THEN - [pastdue].[PastDueFeeAmount]
ELSE 0 END, [AmountDue] = [unpaid].[UnpaidFeeAmount], [ID] = [iff].[FacilityFeeID]
FROM         [dbo].[INV_SubInvoice] isi JOIN
                      [dbo].[INV_Invoice] ii ON [isi].[InvoiceID]
= [ii].[ID] JOIN
                      [dbo].[INV_Facility] [if] ON [isi].[ID] = [if].[SubInvoiceID]
JOIN
                      [dbo].[INV_FacilityFee] iff ON [if].[ID] = [iff].[INV_FacilityID]
JOIN
                          (SELECT     [sis_fee].[ID],
[sis_fee].[SectionTypeCode], [SectionType] = [st_fee].[Name], [sis_fee].[INV_FacilityFeeID]
                            FROM      
   [dbo].[INV_SubInvoiceSection] sis_fee JOIN
               [dbo].[INV_SectionType] st_fee ON [sis_fee].[SectionTypeCode] = [st_fee].[Code]
                            WHERE      [INV_FacilityFeeID]
IS NOT NULL AND [StatusCode] = 'BILL') isis_fee ON [iff].[ID] = [isis_fee].[INV_FacilityFeeID] JOIN
                          (SELECT     [iffa].[SectionID],
[AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]), 
               [AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[AccruedFeeAmount]), 
               [ReceivedAmount] = SUM([iffa].[ReceivedFeeAmount])
                            FROM      
   [dbo].[INV_FacilityFeeAccrual] iffa
                            GROUP BY [iffa].[SectionID])
dates ON [isis_fee].[ID] = [dates].[SectionID] LEFT JOIN
                          (SELECT     *
                            FROM      
   [dbo].[INV_FacilityFeeAccrual]) unpaid ON [dates].[SectionID] = [unpaid].[SectionID] AND 
                      [dates].[AccrualDeterminationDateMax] = [unpaid].[AccrualDeterminationDate]
LEFT JOIN
                          (SELECT     [SectionID],
[PastDueFeeAmount] = SUM([PastDueFeeAmount])
                            FROM      
   [dbo].[INV_FacilityFeeAccrual]
                            GROUP BY [SectionID]) pastdue
ON [dates].[SectionID] = [pastdue].[SectionID]
UNION
SELECT     [isi].[InvoiceID], [ii].[DueDate], [SubInvoiceID] = [isi].[ID], [INV_FacilityID] = [if].[ID], [if].[FacilityID],
[FacilityFeeID] = NULL, [il].[LoanID], [isi].[PortfolioID], [isi].[Portfolio], 
                      [PaymentType] = [isis_loan].[SectionType], [Name]
= [il].[Name], [ReceivedAmount], [CurrentDueAmount], [PastDueAmount] = CASE WHEN ISNULL([ReceivedAmount], 
                      0) > 0 THEN [PastDueAmount] + ISNULL([ReceivedAmount],
0) WHEN ISNULL([ReceivedAmount], 0) 
                      < 0 THEN /* We bring past due to zero and
apply rest to current. */ CASE WHEN [PastDueAmount] + ISNULL([ReceivedAmount], 0) 
                      < 0 THEN 0 ELSE [PastDueAmount] + ISNULL([ReceivedAmount],
0) END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                      [PastDueAmount] < 0 THEN 0 ELSE [PastDueAmount]
END, 
                      [PaidAmount] = CASE WHEN [isis_loan].[SectionTypeCode]
= 'LOAN_PRIN' THEN 0 ELSE CASE WHEN ISNULL([ReceivedAmount], 0) 
                      < 0 THEN /* We bring past due to zero and
apply rest to current. */ CASE WHEN [PastDueAmount] + ISNULL([ReceivedAmount], 0) 
                      < 0 THEN - ([PastDueAmount] + ISNULL([ReceivedAmount],
0)) ELSE 0 END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                      [PastDueAmount] < 0 THEN - [PastDueAmount]
ELSE 0 END END, 
                      [AmountDue] = CASE WHEN [isis_loan].[SectionTypeCode]
= 'LOAN_PRIN' THEN [CurrentDueAmount] ELSE [unpaid].[AmountDue] END, [ID] = [il].[LoanID]
FROM         [dbo].[INV_SubInvoice] isi JOIN
                      [dbo].[INV_Invoice] ii ON [isi].[InvoiceID]
= [ii].[ID] JOIN
                      [dbo].[INV_Facility] [if] ON [isi].[ID] = [if].[SubInvoiceID]
JOIN
                      [dbo].[INV_Loan] il ON [if].[ID] = [il].[INV_FacilityID]
JOIN
                          (SELECT     [sis_loan].[ID],
[sis_loan].[SectionTypeCode], [SectionType] = [st_loan].[Name], [sis_loan].[INV_LoanID]
                            FROM      
   [dbo].[INV_SubInvoiceSection] sis_loan JOIN
               [dbo].[INV_SectionType] st_loan ON [sis_loan].[SectionTypeCode] = [st_loan].[Code]
                            WHERE      [INV_LoanID]
IS NOT NULL AND [StatusCode] = 'BILL') isis_loan ON [il].[ID] = [isis_loan].[INV_LoanID] JOIN
                          (SELECT     [iffa].[SectionID],
[AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]), 
               [AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[ExpectedPrincipalAmount]), 
               [ReceivedAmount] = SUM([ReceivedPrincipalAmount])
                            FROM      
   [dbo].[INV_LoanPrincipalAmortization] iffa
                            GROUP BY [iffa].[SectionID]
                            UNION
                            SELECT     [iffa].[SectionID],
[AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]), 
              [AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[AccruedInterestAmount]), 
              [ReceivedAmount] = SUM([ReceivedInterestAmount])
                            FROM      
  [dbo].[INV_LoanCashInterestAccrual] iffa
                            GROUP BY [iffa].[SectionID]
                            UNION
                            SELECT     [iffa].[SectionID],
[AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]), 
              [AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[AccruedInterestAmount]), 
              [ReceivedAmount] = SUM([ReceivedInterestAmount])
                            FROM      
  [dbo].[INV_LoanPIKInterestAccrual] iffa
                            GROUP BY [iffa].[SectionID])
dates ON [isis_loan].[ID] = [dates].[SectionID] LEFT JOIN
                          (SELECT     [AmountDue]
= [UnpaidPrincipalAmount], [SectionID], [AccrualDeterminationDate]
                            FROM      
   [dbo].[INV_LoanPrincipalAmortization]
                            UNION
                            SELECT     [AmountDue]
= [UnpaidInterestAmount], [SectionID], [AccrualDeterminationDate]
                            FROM      
  [dbo].[INV_LoanCashInterestAccrual]
                            UNION
                            SELECT     [AmountDue]
= [UnpaidInterestAmount], [SectionID], [AccrualDeterminationDate]
                            FROM      
  [dbo].[INV_LoanPIKInterestAccrual]) unpaid ON [dates].[SectionID] = [unpaid].[SectionID] AND 
                      [dates].[AccrualDeterminationDateMax] = [unpaid].[AccrualDeterminationDate]
LEFT JOIN
                          (SELECT     [PastDueAmount]
= SUM([PastDuePrincipalAmount]), [SectionID]
                            FROM      
   [dbo].[INV_LoanPrincipalAmortization]
                            GROUP BY [SectionID]
                            UNION
                            SELECT     [PastDueAmount]
= SUM([PastDueInterestAmount]), [SectionID]
                            FROM      
  [dbo].[INV_LoanCashInterestAccrual]
                            GROUP BY [SectionID]
                            UNION
                            SELECT     [PastDueAmount]
= SUM([PastDueInterestAmount]), [SectionID]
                            FROM      
  [dbo].[INV_LoanPIKInterestAccrual]
                            GROUP BY [SectionID]) pastdue
ON [dates].[SectionID] = [pastdue].[SectionID]
UNION
SELECT     [isi].[InvoiceID], [ii].[DueDate], [SubInvoiceID] = [isi].[ID], [INV_FacilityID] = [if].[ID], [if].[FacilityID],
[FacilityFeeID] = NULL, [il].[LoanID], [isi].[PortfolioID], [isi].[Portfolio], 
                      [PaymentType] = 'PIK Interest Applied', [Name]
= [il].[Name], [ReceivedAmount], [CurrentDueAmount] = - [dates].[CurrentDueAmount], 
                      [PastDueAmount] = - CASE WHEN ISNULL([ReceivedAmount],
0) > 0 THEN [PastDueAmount] + ISNULL([ReceivedAmount], 0) WHEN ISNULL([ReceivedAmount], 0) 
                      < 0 THEN /* We bring past due to zero and
apply rest to current. */ CASE WHEN [PastDueAmount] + ISNULL([ReceivedAmount], 0) 
                      < 0 THEN 0 ELSE [PastDueAmount] + ISNULL([ReceivedAmount],
0) END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                      [PastDueAmount] < 0 THEN 0 ELSE [PastDueAmount]
END, [PaidAmount] = - CASE WHEN ISNULL([ReceivedAmount], 0) 
                      < 0 THEN /* We bring past due to zero and
apply rest to current. */ CASE WHEN [PastDueAmount] + ISNULL([ReceivedAmount], 0) 
                      < 0 THEN - ([PastDueAmount] + ISNULL([ReceivedAmount],
0)) ELSE 0 END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                      [PastDueAmount] < 0 THEN - [PastDueAmount]
ELSE 0 END, [AmountDue] = - [AmountDue], [ID] = [il].[LoanID]
FROM         [dbo].[INV_SubInvoice] isi JOIN
                      [dbo].[INV_Invoice] ii ON [isi].[InvoiceID]
= [ii].[ID] JOIN
                      [dbo].[INV_Facility] [if] ON [isi].[ID] = [if].[SubInvoiceID]
JOIN
                      [dbo].[INV_Loan] il ON [if].[ID] = [il].[INV_FacilityID]
JOIN
                          (SELECT     [sis_loan].[ID],
[sis_loan].[SectionTypeCode], [SectionType] = [st_loan].[Name], [sis_loan].[INV_LoanID]
                            FROM      
   [dbo].[INV_SubInvoiceSection] sis_loan JOIN
               [dbo].[INV_SectionType] st_loan ON [sis_loan].[SectionTypeCode] = [st_loan].[Code]
                            WHERE      [INV_LoanID]
IS NOT NULL AND [StatusCode] = 'BILL' AND [sis_loan].[SectionTypeCode] = 'LOAN_INT_PIK') isis_loan ON 
                      [il].[ID] = [isis_loan].[INV_LoanID] JOIN
                          (SELECT     [iffa].[SectionID],
[AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]), 
               [AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[AccruedInterestAmount]), 
               [ReceivedAmount] = SUM([ReceivedInterestAmount])
                            FROM      
   [dbo].[INV_LoanPIKInterestAccrual] iffa
                            GROUP BY [iffa].[SectionID])
dates ON [isis_loan].[ID] = [dates].[SectionID] LEFT JOIN
                          (SELECT     [AmountDue]
= [UnpaidInterestAmount], [SectionID], [AccrualDeterminationDate]
                            FROM      
   [dbo].[INV_LoanPIKInterestAccrual]) unpaid ON [dates].[SectionID] = [unpaid].[SectionID] AND 
                      [dates].[AccrualDeterminationDateMax] = [unpaid].[AccrualDeterminationDate]
LEFT JOIN
                          (SELECT     [PastDueAmount]
= SUM([PastDueInterestAmount]), [SectionID]
                            FROM      
   [dbo].[INV_LoanPIKInterestAccrual]
                            GROUP BY [SectionID]) pastdue
ON [dates].[SectionID] = [pastdue].[SectionID]

Similar Messages

  • How can i get the source code from java concurrent program in R12

    Hi 2 all,
    How can i get the source code from java concurrent program in R12? like , "AP Turnover Report" is java concurrent program, i need to get its source code to know its logic. how can i get its source code not the XML template?
    Regards,
    Zulqarnain

    user570667 wrote:
    Hi 2 all,
    How can i get the source code from java concurrent program in R12? like , "AP Turnover Report" is java concurrent program, i need to get its source code to know its logic. how can i get its source code not the XML template?
    Regards,
    ZulqarnainDid you see old threads for similar topic/discussion? -- https://forums.oracle.com/forums/search.jspa?threadID=&q=Java+AND+Concurrent+AND+Source+AND+Code&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

  • How to get the source code of a PRT application in the portal

    Hi!
    Does anybody know how to get the source code of a PRT application in the portal?
    Thanks in advance,
    Celso

    Celso,
    If its Java-based code have a look at the properties of an iView that belongs to the application in question and copy the value of the Code Link parameter e.g. 'com.sap.pct.hcm.rc_vacancyrequestov.default'.
    Search the Portal installation directory under /j233/cluster/server/ for a .par.bak file of the same name, removing .default from the codelink parameter
    e.g. com.sap.pct.hcm.rc_vacancyrequestov.par.bak
    Copt this locally and import into Netweaver Developer Studio. You will have to decompilte the class files with a decompiler such as DJ Decompiler or Cavaj (search with Google).
    Cheers,
    Steve

  • Access the source code from an HTML component

    Is there a method to access the source code of a page in the HTML component?
    I can't use URLLoader or HTTPService because of cross domain policies, so I need to use the HTML component to load the page, then access the source.

    Is there a method to access the source code of a page in the HTML component?
    I can't use URLLoader or HTTPService because of cross domain policies, so I need to use the HTML component to load the page, then access the source.

  • Finding the source code from Jar file

    Hi,
    I am a beginner java programmer but have been entrusted with learning our company's Java application. The architect of the application is not forthcoming in sharing information and so I need help in tracing the source code for the application. I know where the .jar files are stored but I don't know where the actual .java or .class files are stored.
    In the .profile file, I see the classpaths set to various jar files. eg.
    CLASSPATH=$PATH:/eaid01_apps/merc01/libs/tools/java/drivers/bin/eaiRun.jar
    When I view this jar file with command "jar tf eaiRun.jar", it displays all the files under it. Onc such listing is as following:
    citi/eai/EAI.class
    citi/eai/Interface.class
    I want to go to that specific directory on our file system which is storing these .class or.java file. From what I have learned about packages, I should find some folder called 'citi' ,'eai'.
    However I am not able to find these folders anywhere on file system. Is there a way I can find where the actual souce code is by looking at the jar files.
    Please help. Let me know if you need more information.
    thanks,
    Anand.

    Is there a way I can find where the actual souce code is by looking at the jar files.No, in general you can't, you should ask the architect that you mentioned earlier. The name of the source file is sometimes stored in the .class file for debugging purposes but that's unlikely going to help you find the files.
    You should also ask if he/she has got any documentation of the system. It's often a lot easier to follow documentation written in human language than program code written in a programming language. There could be documentation in a format similar to this: http://java.sun.com/j2se/1.4.2/docs/api/

  • Extracting the largest code from a specific section in the report

    Post Author: MikeA-ICE
    CA Forum: General
    I have a report that has 8 sections, called Report Areas. Each area is limited by a range of codes (Group1). For the whole report the codes range from 01 to 93. There is one particular area in the report, Area 2, that spans 01 to 29. I need to extract the largest code from Area 2 but I never know from one time to the next when running the report what codes will be included. There could be any number of codes in a particular run of the report. I could have 1, 3,4,5, 7, 11, & 16 one time and 1, 2, 3, 8, 9, 12, 21, 23, and 28 the next. I tried this formula:If {CBIRptTotalSummary.ReportArea} = 2ThenNthLargest (1, {CBIRptTotalSummary.Group1})This consistently printed 93 in Area 2 of the report since 93 is the largest code of Group1 in the report. I've tried numerous other formulas and I can't get Crystal to look only at the groups contained in Area 2 and tell me what the largest group is in that area. How would I accomplish this? Thanks  very much for your help!!Mike

    Post Author: Jagan
    CA Forum: General
    Do you group on ReportArea?If so, it's the maximum(Group1, ReportArea)

  • How would I go about removing the required code from a form field?

    I have this contact form that I downloaded and its fine. I just need to know how to remove the required field code from the contact no field.
    Thanks in advance
    Here is a link to the form and all of its assets
    http://www.formget.com/jquery-contact-form/#comment-93253

    HTML code, change this:
    <label>Contact No: <span>*</span></label>
    To this:
    <label>Contact No:</label>
    jQuery code, change this:
    if (name == '' || email == '' || contact == '') {
    alert("Please Fill Required Fields");
    } else {
    to this:
    if (name == '' || email == '') {
    alert("Please Fill Required Fields");
    } else {
    Nancy O.

  • Need help understanding a line of code from the Java Tutorial

    Here is the code I have seen in the Reflection Tutorial:
    import java.lang.reflect.*;
    class SampleInvoke {
       public static void main(String[] args) {
          String firstWord = "Hello ";
          String secondWord = "everybody.";
          String bothWords = append(firstWord, secondWord);
          System.out.println(bothWords);
       public static String append(String firstWord, String secondWord) {
          String result = null;
          Class c = String.class;
          Class[] parameterTypes = new Class[] {String.class};
          Method concatMethod;
          Object[] arguments = new Object[] {secondWord};
          try {
            concatMethod = c.getMethod("concat", parameterTypes);
            result = (String) concatMethod.invoke(firstWord, arguments);
          } catch (NoSuchMethodException e) {
              System.out.println(e);
          } catch (IllegalAccessException e) {
              System.out.println(e);
          } catch (InvocationTargetException e) {
              System.out.println(e);
          return result;
    }There are 2 lines I do not understand (but once I understand one, I'll understand the other).
    Here they are:
    Class[] parameterTypes = new Class[] {String.class};
    Object[] arguments = new Object[] {secondWord};Any explanation will be greatly appreciated :)

    There are 2 lines I do not understand (but once I
    understand one, I'll understand the other).
    Here they are:
    Class[] parameterTypes = new Class[]
    {String.class};
    Object[] arguments = new Object[]
    {secondWord};
    the first line simply creates an array of objects, the objects are of type Class. It then places the object referenced in the brackets into the array.

  • How to hide the source code from the .class file

    Hi,
    By some jad tool we can recompile the .class files and get the java file corresponding to it. How to protect it?
    Anyone please help me..
    Thanks & Regards,
    N.Ravasankar

    An obfuscator can for example rename classes, variables to meaningless names, like one-letter names. And it can make some bytecode that is hard to decompile or just makes the code less readable when decompiled. Some obfuscators might even be able to do something to the code that makes decompilers not work or incorrect decompile code.

  • View code from .fmx forms

    Can i see the source code from an .fmx file?

    The rep file is binary also.
    See
    http://www.oracle.com/webapps/online-help/reports/10.1.2/state/content/navId.3/navSetId._/vtTopicFile.htmlhelp_rwbuild_hs%7Crwrefex%7Cfiles%7Cf_supported_files~htm/
    Message was edited by:
    Mark Roberts

  • How to display the source code for this friggin' file.

    Below is a rather lengthy bit of code that provides the behavior and attributes of a web server for OpenCyc. I need to know if I can enter some java to have the HTML source code displayed in a separate text file whenever this class returns some resulting webpage. If you have any ideas it will be greatly appreciated.
    -"Will code for foo."
    package org.opencyc.webserver;
    * Class WebServer is simple multithreaded HTTP server
    * with CGI limited to a Cyc connection on default port 3600.
    * <p>
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import java.util.jar.*;
    import java.text.*;
    import org.opencyc.util.*;
    public class WebServer extends Thread {
         * Singleton WebServer instance.
        public static WebServer current;
         * Default HTTP port.
        protected static int DEFAULT_PORT = 80;
         * Default Cyc base port.
        protected static int DEFAULT_CYC_PORT = 3600;
         * Default directory to serve files from on non-Windows OS.
        protected static String DEFAULT_DIR = "/";
         * Default directory to serve files from on Windows.
        //protected static String DEFAULT_WIN_DIR = "C:\\";
        protected static String DEFAULT_WIN_DIR = "k:\\opencyc\\run\\httpd\\htdocs";
         * File cache capacity.
        protected static final int CACHE_CAPACITY = 100;
         * File cache to improve file serving performance.
        protected static Hashtable fileCache = new Hashtable(CACHE_CAPACITY);
         * Number of files served from this web server.
        protected static long nbrFilesServed = 0;
         * Number of files served from this web server that were found in the cache.
        protected static long nbrCacheHits = 0;
         * Server socket for accepting connections.
        protected ServerSocket server;
         * Directories to serve files from.
        protected ArrayList dirs;
         * Map from String (jar root) to JarFile[] (jar class path).
        protected HashMap map;
         * Webserver HTTP port.
        protected int port;
         * Cyc HTML host.
        protected String cycHost = "localhost";
         * Cyc HTML port.
        protected int cycPort;
         * Expand jar tress.
        protected boolean trees;
         * Requests flag.
        protected boolean traceRequests;
         * Constructs a WebServer object.
         * @param port the port to use
         * @param directories the directory to serve files from
         * @param trees true if files within jar files should be served up
         * @param traceRequests true if client's request text should be logged.
         * @exception IOException if the listening socket cannot be opened, or problem opening jar files.
        public WebServer() throws IOException {
            getProperties();
            server = new ServerSocket(port);
            processDirectories();
         * Class Task processes a single HTTP request.
        protected class Task extends Thread {
             * Socket for the incoming request.
            protected Socket sock;
             * Client socket to the Cyc KB HTML server.
            protected Socket cycHtmlSocket;
             * Output tcp stream.
            protected DataOutputStream out;
             * Contains the file request path for a not-found error message.
            protected String notFoundPath;
             * Contains the first line of a request message.
            protected String methodLine;
             * Contains the body of a POST method.
            protected String bodyLine;
             * Constructs a Task object.
             * @param sock the socket assigned for this request.
            public Task(Socket sock) {
                this.sock = sock;
             * Processes the HTTP request.
            public void run() {
                if (traceRequests)
                    Log.current.println("connection accepted from " + sock.getInetAddress());
                notFoundPath = "";
                try {
                    out = new DataOutputStream(sock.getOutputStream());
                    try {
                        getBytes();
                    catch (Exception e) {
                        Log.current.println("file not found: " + notFoundPath);
                        try {
                            out.writeBytes("HTTP/1.1 404 Not Found\r\n");
                            out.writeBytes("Server: Cyc WebServer\r\n");
                            out.writeBytes("Connection: close\r\n");
                            out.writeBytes("Content-Type: text/html\r\n\r\n");
                            out.writeBytes("<HTML><HEAD>\n");
                            out.writeBytes("<TITLE>404 Not Found</TITLE>\n");
                            out.writeBytes("</HEAD><BODY>\n");
                            out.writeBytes("<H1>404 - Not Found</H1>\n");
                            out.writeBytes("</BODY></HTML>");
                            out.flush();
                        catch (SocketException se) {
                catch (Exception e) {
                    Log.current.printStackTrace(e);
                finally {
                    try {
                        sock.close();
                    catch (IOException e) {
             * Reads the HTTP request and obtains the response.
             * @exception IOException when HTTP request has an invalid format.
            private void getBytes() throws IOException {
                // Below logic is complex because web browsers do not close the
                // socket after sending the request, so must parse message to find
                // the end.
                BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
                ArrayList inBytes = new ArrayList(200);
                int ch = 0;
                boolean postMethod;
                methodLine = in.readLine();
                //if (traceRequests)
                //    Log.current.println("methodLine=" + methodLine);
                bodyLine = "";
                if (methodLine.startsWith("POST /"))
                    postMethod = true;
                else
                    postMethod = false;
                //if (traceRequests)
                //    Log.current.println("postMethod=" + postMethod);
                int ch1 = -1;
                int ch2 = -1;
                int ch3 = -1;
                int ch4 = -1;
                // Read the HTTP request headers.
                while (true) {
                    ch = in.read();
                    inBytes.add(new Integer(ch));
                    ch1 = ch2;
                    ch2 = ch3;
                    ch3 = ch4;
                    ch4 = ch;
                    if (ch1 == '\r' && ch2 == '\n' && ch3 == '\r' && ch4 == '\n')
                        break;
                    if ((! postMethod) &&
                        (! in.ready()) &&
                        ch1 == -1 &&
                        ch2 == -1 &&
                        ch3 == '\r' &&
                        ch4 == '\n') {
                        inBytes.add(new Integer('\r'));
                        inBytes.add(new Integer('\n'));
                        break;
                byte[] byteArray = new byte[inBytes.size()];
                for (int i = 0; i < inBytes.size(); i++) {
                    Integer ich = (Integer) inBytes.get(i);
                    byteArray[i] = ich.byteValue();
                String headers = new String(byteArray);
                if (postMethod) {
                    String lcHeaders = headers.toLowerCase();
                    int i = lcHeaders.indexOf("content-length: ");
                    String contentLength = lcHeaders.substring(i + 16);
                    int j = contentLength.indexOf("\r\n");
                    contentLength = contentLength.substring(0, j);
                    int bodyLen = (new Integer(contentLength)).intValue();
                    for (int k = 0; k < bodyLen; k++) {
                        bodyLine = bodyLine + (new Character((char) in.read())).toString();
                String line = methodLine + "\r\n" + headers + bodyLine;
                if (traceRequests)
                    Log.current.println(line);
                if (postMethod)
                    processHttpPost();
                else
                    if (line.startsWith("GET /"))
                        processHttpGet(line.substring(4));
                    else {
                        Log.current.println("Invalid request = " + line);
                        throw new IOException();
             * Processes an HTTP GET method.
             * @param httpGetPath the path of the file to get.
             * @exception IOException if the file is not found.
            private void processHttpGet(String httpGetPath) throws IOException {
                int i = httpGetPath.indexOf(' ');
                if (i > 0)
                    httpGetPath = httpGetPath.substring(0, i);
                Log.current.println(methodLine + " from " + sock.getInetAddress().getHostName());
                i = httpGetPath.indexOf("cg?");
                if (i > 0) {
                    cycHtmlRequest(httpGetPath.substring(i + 3));
                    return;
                notFoundPath = httpGetPath;
                i = httpGetPath.indexOf('/');
                if (i < 0 || map == null) {
                    if (map == null || httpGetPath.endsWith(".jar")) {
                        for (int j = 0; j < dirs.size(); j++) {
                            String dir = (String) dirs.get(j);
                            String nativePath = dir + httpGetPath;
                            nativePath = nativePath.replace('/', File.separatorChar);
                            if (fileCache.containsKey(nativePath)) {
                                writeDataBytes((byte[]) fileCache.get(nativePath));
                                Log.current.println("...cached");
                                nbrCacheHits++;
                                nbrFilesServed++;
                                return;
                            try {
                                File f = new File(nativePath);
                                byte[] fileBytes = getBytes(new FileInputStream(f), f.length());
                                writeDataBytes(fileBytes);
                                if (fileCache.size() >= CACHE_CAPACITY)
                                    fileCache.clear();
                                fileCache.put(nativePath, fileBytes);
                                Log.current.println("...from " + nativePath);
                                nbrFilesServed++;
                                return;
                            catch (IOException e) {
                    throw new IOException();
                String jar = httpGetPath.substring(0, i);
                httpGetPath = httpGetPath.substring(i + 1);
                JarFile[] jfs = (JarFile[]) map.get(jar);
                if (jfs == null)
                    throw new IOException();
                for (i = 0; i < jfs.length; i++) {
                    JarEntry je = jfs.getJarEntry(httpGetPath);
    if (je == null)
    continue;
    writeDataBytes(getBytes(jfs[i].getInputStream(je), je.getSize()));
    nbrFilesServed++;
    return;
    throw new IOException();
    * Processes an HTTP POST method.
    * @exception IOException if the file is not found.
    private void processHttpPost() throws IOException {
    Log.current.println("POST " + bodyLine + " from " + sock.getInetAddress().getHostName());
    cycHtmlRequest(bodyLine);
    * Reads the specified number of bytes and always close the stream.
    * @param in the file to be read for subsequent downloading.
    * @param length the number of bytes to read from the file.
    * @return An array of bytes from the file.
    * @exception IOException if an error occurs when processing the file.
    private byte[] getBytes(InputStream in, long length) throws IOException {
    DataInputStream din = new DataInputStream(in);
    byte[] bytes = new byte[ (int) length];
    try {
    din.readFully(bytes);
    finally {
    din.close();
    return bytes;
    * Sends the HTML request to Cyc.
    * @param cycPath the portion of the URL which is given to the Cyc HTML server.
    private void cycHtmlRequest(String cycPath) {
    String request = sock.getInetAddress().getHostName() + "&" + cycPath + "#";
    System.out.println("request=" + request);
    ArrayList bytes = new ArrayList(10000);
    try {
    cycHtmlSocket = new Socket(cycHost, cycPort);
    System.out.println("cycHost=" + cycHost + " cycPort=" + cycPort);
    BufferedReader cycIn = new BufferedReader(new InputStreamReader(cycHtmlSocket.getInputStream()));
    PrintWriter cycOut = new PrintWriter(cycHtmlSocket.getOutputStream(), true);
    cycOut.println(request);
    cycOut.flush();
    int ch = 0;
    while (ch >= 0) {
    ch = cycIn.read();
    bytes.add(new Integer(ch));
    catch (Exception e) {
    Log.current.printStackTrace(e);
    byte[] byteArray = new byte[bytes.size()];
    for (int i = 0; i < bytes.size() - 1; i++) {
    Integer ich = (Integer) bytes.get(i);
    byteArray[i] = ich.byteValue();
    try {
    writeTextBytes(byteArray);
    catch (Exception e) {
    Log.current.println(e.getMessage());
    * Responds to the HTTP client with data content from the requested URL.
    * @param bytes the array of bytes from the URL.
    * @exception IOException if there is an error writing to the HTTP client.
    public void writeDataBytes(byte[] bytes) throws IOException {
    out.writeBytes("HTTP/1.1 200 OK\r\n");
    out.writeBytes("Server: Cyc WebServer\r\n");
    out.writeBytes("Connection: close\r\n");
    out.writeBytes("Content-Length: " + bytes.length + "\r\n");
    String prefix = (new String(bytes)).toLowerCase();
    if (prefix.indexOf("<html>") > -1)
    out.writeBytes("Content-Type: text/html\r\n\r\n");
    else
    out.writeBytes("Content-Type: application/java\r\n\r\n");
    out.write(bytes);
    out.flush();
    * Respond to the HTTP client with text content from the requested URL.
    * @param bytes the array of bytes from the URL.
    * @exception IOException if there is an error writing to the HTTP client.
    public void writeTextBytes(byte[] bytes) throws IOException {
    out.writeBytes("HTTP/1.1 200 OK\r\n");
    out.writeBytes("Server: Cyc WebServer\r\n");
    out.writeBytes("Connection: close\r\n");
    out.writeBytes("Content-Length: " + bytes.length + "\r\n");
    out.writeBytes("Content-Type: text/html\r\n\r\n");
    out.write(bytes);
    out.flush();
    * Gets properties governing the web server's behavior.
    private void getProperties() {
    port = DEFAULT_PORT;
    String portProperty = System.getProperty("org.opencyc.webserver.port", "");
    if (! portProperty.equalsIgnoreCase(""))
    port = (new Integer(portProperty)).intValue();
    Log.current.println("Listening on port " + port);
    cycPort = DEFAULT_CYC_PORT;
    String cycPortProperty = System.getProperty("org.opencyc.webserver.cycPort", "");
    if (! cycPortProperty.equalsIgnoreCase(""))
    cycPort = (new Integer(cycPortProperty)).intValue();
    Log.current.println("Cyc connections directed to port " + cycPort);
    String dirsProperty = System.getProperty("org.opencyc.webserver.dirs", "");
    dirs = new ArrayList(3);
    StringTokenizer st = new StringTokenizer(dirsProperty, ";", false);
    while (st.hasMoreTokens()) {
    String dir = st.nextToken();
    dirs.add(dir);
    trees = false;
    String treesProperty = System.getProperty("org.opencyc.webserver.trees", "");
    if (! treesProperty.equalsIgnoreCase(""))
    trees = true;
    traceRequests = false;
    String traceRequestsProperty = System.getProperty("org.opencyc.webserver.traceRequests", "");
    if (! traceRequestsProperty.equalsIgnoreCase("")) {
    traceRequests = true;
    Log.current.println("tracing requests");
    * Adds transitive Class-Path jars to jfs.
    * @param jar the jar file
    * @param jfs the list of jar files to serve.
    * @param dir the jar file directory.
    * @exception IOException if an I/O error has occurred with the jar file.
    private void addJar(String jar, ArrayList jfs, String dir) throws IOException {
    Log.current.println("Serving jar files from: " + dir + jar);
    JarFile jf = new JarFile(dir + jar);
    jfs.add(jf);
    Manifest man = jf.getManifest();
    if (man == null)
    return;
    Attributes attrs = man.getMainAttributes();
    if (attrs == null)
    return;
    String val = attrs.getValue(Attributes.Name.CLASS_PATH);
    if (val == null)
    return;
    dir = dir + jar.substring(0, jar.lastIndexOf(File.separatorChar) + 1);
    StringTokenizer st = new StringTokenizer(val);
    while (st.hasMoreTokens()) {
    addJar(st.nextToken().replace('/', File.separatorChar), jfs, dir);
    * Administrative accessor method that obtains list of directories from which files are served.
    public ArrayList getDirs() {
    return dirs;
    * Administrative method that updates the list of directories from which files are served.
    public synchronized void setDirs(ArrayList dirs) throws IOException {
    this.dirs = dirs;
    fileCache.clear();
    processDirectories();
    * Administrative accessor method that obtains number of files served.
    * @return The number of files served.
    public long getNbrFilesServed() {
    return nbrFilesServed;
    * Administrative accessor method that obtains number of files served from cache.
    * @return The number of files served from the cache.
    public long getNbrCacheHits() {
    return nbrCacheHits;
    * Administrative method that clears the file cache.
    public synchronized void clearFileCache() {
    Log.current.println("Clearing file cache");
    fileCache.clear();
    nbrFilesServed = 0;
    nbrCacheHits = 0;
    * Processes the directories from which files are served, expanding jar trees if
    * directed.
    * @exception IOException if problem occurs while processing the jar files.
    private void processDirectories() throws IOException {
    if (dirs.size() == 0)
    if (File.separatorChar == '\\')
    dirs.add(DEFAULT_WIN_DIR);
    else
    dirs.add(DEFAULT_DIR);
    Iterator directories = dirs.iterator();
    while (directories.hasNext())
    Log.current.println("Serving from " + directories.next());
    if (trees) {
    map = new HashMap();
    for (int j = 0; j < dirs.size(); j++) {
    String dir = (String) dirs.get(j);
    String[] files = new File(dir).list();
    for (int i = 0; i < files.length; i++) {
    String jar = files[i];
    if (!jar.endsWith(".jar"))
    continue;
    ArrayList jfs = new ArrayList(1);
    addJar(jar, jfs, dir);
    map.put(jar.substring(0, jar.length() - 4), jfs.toArray(new JarFile[jfs.size()]));
    * Provides the command line interface for creating an HTTP server.
    * The properties are:
    * <pre>
    * org.opencyc.webserver.port=<HTTP listening port>
    * </pre>
    * which defaults to 80.
    * <pre>
    * org.opencyc.webserver.cycPort=<Cyc connection port>
    * </pre>
    * which defaults to 3600.
    * <pre>
    * org.opencyc.webserver.dirs=<path>;<path> ... ;<path>
    * </pre>
    * with the argument enclosed in quotes if any path contains an
    * embedded space.
    * The default directory on Windows is C:
    * and the default on other systems is / the default
    * can be overridden with this property. By default, all files
    * under this directory (including all subdirectories) are served
    * up via HTTP. If the pathname of a file is <var>path</var> relative
    * to the top-level directory, then the file can be downloaded using
    * the URL
    * <pre>
    * http://<var>host</var>:<var>port</var>/<var>path</var>
    * </pre>
    * Caching of file contents is performed.
    * <pre>
    * org.opencyc.util.log=all
    * </pre>
    * If the all value is given, then all attempts to download files
    * are output.
    * <pre>
    * org.opencyc.webserver.traceRequests
    * </pre>
    * If this property has any value, then the client HTTP requests are
    * output.<p>
    * <pre>
    * org.opencyc.webserver.trees
    * </pre>
    * This property can be used to serve up individual files stored
    * within jar files in addition to the files that are served up by
    * default. If the property has any value, the server finds all jar files
    * in the top-level directory (not in subdirectories). For each
    * jar file, if the name of the jar file is <var>name</var>.jar, then any
    * individual file named <var>file</var> within that jar file (or within
    * the jar or zip files referenced transitively in the Class-Path manifest
    * attribute, can be downloaded using a URL of the form:
    * <pre>
    * http://<var>host</var>:<var>port</var>/<var>name</var>/<var>file</var>
    * </pre>
    * When this property has any value, an open file descriptor and cached
    * information are held for each jar file, for the life of the process.
    * @param args an unused array of command line arguments.
    public static void main(String[] args) {
    Log.makeLog();
    System.out.println("OpenCyc Web Server");
    try {
    // Launch thread to accept HTTP connections.
    current = new WebServer();
    current.start();
    catch (IOException e) {
    e.printStackTrace();
    * Just keep looping, spawning a new thread for each incoming request.
    public void run() {
    try {
    while (true) {
    // Launch thread to process one HTTP request.
    new Task(server.accept()).start();
    catch (IOException e) {
    e.printStackTrace();

    JLundan,
    I want to thank you for responding to the thread I started on the forum at java.sun.com. Your solution to my problem of needing to print the code of the html pages that the file I included generates was just what I was looking for. However, I have some further questions to ask, if you don't mind. To clarify my task I should say that your rephrasing of the problem is accurate: "You wan't to display the contents of the HTML file that the web server produces in response of client's request?"
    Yes, this is what I need to do, but also it needs to display the source code of that html file that the server produces in response to the client's request. Also, in this case, I am the client requesting that the server return some html file, and I'm not sure where the server is. But the webserver.java file that I shared on the forum is on my local machine. I was wondering if I could modify this webserver.java file at my home so that any html file the server returns to me would automatically display the source code. This is a school project of mine and I am stuck on this one thing here.
    Further, where would I put the "foo.html" file so it can be written to?
    FileOuputStream fos = new FileOutputStream("foo.html");
    fos.write(bytes);
    fos.close();
    Thanks so much for your help. I look forward to your response, at your convenience.
    Regards

  • How to get the source code in PAR file

    Hi All,
    I used the PAR migration tool to migrate from PAR to EAR file. When I imported the EAR into NWDS 7.3, I was just able to see the structure and jsp files and could not find the java source code files. I would requires the java source code to make modifications so that deprecated APIs can be replaced and to also make the code compatible with JDK 1.6.
    I think the original 7.0 PAR file itself does not contain the source code. I decided to use the "Include source code" option when exporting the 7.0 PAR.
    I have the portal application DC project in my NWDS 7.0. However, when I try to export the PAR file using Export --> PAR File -- > Next... I am unable to select any project from the list. The list appears blank with disabled Next & Finish buttons.
    I also noticed that in the portal DC application structure, there is a .sda file under /gen/default/deploy. Also there is no PAR folder under /gen/default/public.
    How do I include the source in the PAR file so that I can edit the same after migrating to EAR format ?
    Regards,
    Melwyn

    DC and PAR/EAR stuff are different formats, SC/DC is an archive type used by NWDI, if I got it right.
    How do I go about generating the PAR file (with source) ?
    In fact through including the seources while creating the PAR/EAR in NWDS, but: no need to do that, you can also depack SDA (rename it to zip). If you wanna just see the Java sources you will find them there, otherwise decompile as Vijay already sad.
    cheers

  • W3_PUBLISH_SERVICES and dump while viewing the source code in se80

    Hi,
    external ITS6.20  on SAP R/3 4.7
    we have installed ITS and we published the templates. When we published the teampltes using the standard prgram   W3_PUBLISH_SERVICES, and around 43 of the services fail  Not sure if this is an error
    After the upgrade is finished, you must make this up, before you can use the Internet applications of the system. For a detailed procedure description see Note 399578.
    or not.
    On the other hand when i go to se 80 and try to view the source code of any ITS service lets say PZM3 in my case, the entire application goes for a dump with error
    Exception condition "INVALID PARAM VERB: TEXTSTREAM" raised.
    What happened?
    The current ABAP/4 program encountered an unexpected
    situation.
    What can you do?
    Print out the error message (using the "Print" function)
    and make a note of the actions and input that caused the
    error.
    To resolve the problem, contact your SAP system administrator.
    You can use transaction ST22 (ABAP Dump Analysis) to view and administer
    termination messages, especially those beyond their normal deletion
    date.
    Error analysis
    A RAISE statement in the program "SAPLOLEA " raised the exception
    condition "INVALID PARAM VERB: TEXTSTREAM".
    Since the exception was not intercepted by a superior program
    in the hierarchy, processing was terminated.
    Short description of exception condition:
    For detailed documentation of the exception condition, use
    Transaction SE37 (Function Library). You can take the called
    function module from the display of active calls.
    How to correct the error
    You may able to find an interim solution to the problem
    in the SAP note system. If you have access to the note system yourself,
    use the following search criteria:
    The termination occurred in the ABAP program "SAPLOLEA " in
    "AC_FLUSH_CALL_INTERNAL".
    The main program was "SAPMSEU0 ".
    The termination occurred in line 220 of the source code of the (Include)
    program "LOLEAU10 "
    of the source code of program "LOLEAU10 " (when calling the editor 2200).
    Any deas what the error could be??
    On the other hand i tried to see the Service 'System' and 'webgui' from se80 di dnot find any..
    Any ideas if we are missing in our landscape.
    Message was edited by:
            RajK
    Message was edited by:
            RajK

    Hi RajK
    > On the other hand i tried to see the Service 'System'
    > and 'webgui' from se80 di dnot find any..
    > Any ideas if we are missing in our landscape.
    The services system and webgui are shipped within the installer of ITS 6.20. So you can't find them in the database via SE80, instead only in the filesystem.
    Not your main problem, I know, but I just wanted to clarify.
    Best regards,
    Henning

  • How transfer the source code to customer JDI system

    HI Exprts,
    we have typical requirement of transferring the source code from our JDi system to Customer JDI system.
    We have created one track,in that we have 30-40 DCS.now we want to continue the further development at customer place.for that we want to all the source code to Customer JDI system.
    will it be possibel.
    any help will appriciated
    With Regards
    Shobhan

    Hi Shobhan,
    if your developed SCs are configured as "Sources" or "Sources and Archives" then an assembly (and approval) should include a blob from DTR that contains the sources. Importing those SCAs into a track where the same SC is defined as developed SC will also import the sources into DTR.
    (Those sources do not include the full history, only the active version at the time the assembly was done.)
    Regards,
    Marc

  • Check the source code

    Hi Folks,
    I know it should be very basic question. I am not a complete technical person, but i am trying to understand the code. Please guide me for the below issues.
    How to see the source code for method (which is inside the interface) ?
    [SE24 --> Double Click Interface --> Method tab]
    I can see code for some method by click the Code button in Class --> Methods. But there are some extra method defined inside the interface. How to see those source code.

    place the cursor over that method and click the where - used lists button which will show you all the classes that are using this method
    Thanks
    Bala Duvvuri

Maybe you are looking for

  • Where is the Oracle Application Server for Apex 3.2.1?

    Hi, I feel ashamed asking this, but I want to know where to download the Application Server for Apex 3.2.1. Apex is installed in a DataBase 10gR1 and the O.S. where I will install the Application Server is RedHat I think it is here http://www.oracle.

  • Sync Notes to iPhone

    How do I sync my Entourage Notes with the notes in my iPhone? Thanks John

  • Opening a document with a dialog open

    I am trying to open a document with a window open created by javascript, but I get an error when the window is open and I try to open the document. See attached: Is there no way to have a window open and the application open a document at the same ti

  • How do I get back up to work again..... I pay for this

    trying back up my pins on pin4ever. It gets stuck on93% finished and it stayed like that all night I found a help area that said refresh Firefox by going to the icon in the upper left corner of this page ( 3 bars) and click on t then click on help. T

  • IDOCs issue

    Hello,    When we load data from R3, everything looks good. But when we load data from flat files, the IDOCS get stuck with status 64. We need to manually execute these IDOC's and after which load goes geen. But it happens all the times when we load