Equivalent code for % break;  % in JSTL....... ??????

Hi,
Does anyone know the JSTL equivalent of break; to break out of a loop?
My requirement:
I have to loop through a collection of objects. If a condition is satisfied, I need to set the values and break out of the loop.
P.S: Scriptlet <% break; %> doesn�t work.

There is currently no equivilant to 'break' in JSTL. You have several alternatives:
1) within your <c:forEach>, set a flag variable that is set when your 'break' condition occurs. Only process items before this flag is set. The obvious drawback to this is that you will continue to iterate over a Collection when there is no work to do. If your collections are small, this shouldn't be too bad of an idea.
2) Have your model/controller prune the collection before it gets to your JSP. This way, the collection is guaranteed to only contain items that you are concerned with processing.

Similar Messages

  • Got a code for breaking dawn downloaded it and now it won't go on my nano touch

    got a code for breaking dawn download that works with itunes downloaded and now it won't go on to my ipod nano what cann i do

    What iOS is on the iPod? The app requires 3.0 and later. Was the app purchased with the same iTunes account as the other apps on your iPod?

  • The equivalent code for dbms_output.put_line on DB2

    Its very urgent, plz tell me the equivalent code for dbms_output.put_line on DB2
    thank u,
    Abhilasha.

    And on Sybase ?
    You can perhaps ask this one into the good forum.
    Nicolas.Hallo Nicolas,
    I can imagine the reaction on DB2 forum "dbms_output ? put_line ?
    What is this ?" No way :-))
    Regards
    Dmytro

  • Equivalent code for "matchInternalPointWithExternal

    I'm trying to code an app in Flash Builder 4 which loads a bitmap, then allows zooming centered on a point clicked by the mouse.  Trouble is, to keep the bitmap aligned with the stage as it scales up or down, seems I need to use the MatrixTransformer.matchInternalPointWithExternal method (see http://www.flashandmath.com/howtos/zoom/  or http://www.actionscript.org/forums/showthread.php3?t=181202).  Apparently, this method is only available when using Actionscript with Flash, not with the Flash Builder IDE.  Is this correct? If so, what would be the equivalent code / workaround?
    thanks in advance

    String ss = s[j] == null ? "" : s[j];It does this,
    String ss;
    if (s[j] == null)
       ss = "";
    else
       ss = s[j];

  • Equivalent code for this line?

    What is the equivalent to ---> String ss = s[i][j] == null ? "" : s[i][j];
    I have no idea what ---> ? "" : s[i][j] means. My friend added this to my nested loop for it too work. Is there another equivalent way of doing this that is understandable to the intermediate programmer. Thanks in Advance.
    Here is my code:
         protected void printTable (String[][] s, PrintStream ps)
              int[] maxLen = new int[s[0].length];
              for (int c = 0; c < s[0].length; c++)
                   maxLen[c] = 0;
                   for (int r = 0; r < s.length; r++)
                        String ss = s[r][c] == null ? "" : s[r][c];
                        maxLen[c] = Math.max (maxLen[c], ss.length ());
              for (int i = 0; i < s.length; i++)
                   for (int j = 0; j < s.length; j++)
                        String ss = s[i][j] == null ? "" : s[i][j];
                        ps.print (ss);
                        for (int k = ss.length (); k <= maxLen[j]; k++)
                             ps.print (" ");
                   ps.println ();
              ps.println ();

    String ss = s[j] == null ? "" : s[j];It does this,
    String ss;
    if (s[j] == null)
       ss = "";
    else
       ss = s[j];

  • Equivalent code in JCE for the given C# AES code

    Can somebody give me the equivalent code in JCE for the given C# AES code below?
    (Ofcourse, I checked this topic
    http://forum.java.sun.com/thread.jspa?threadID=603209
    as well, but couldn't figure out much; I have
    little knowledge in this area; I've a job to figure out an equivalent code for
    this and use it in JSP.)
    Thanks,
    RK.
    byte[] bytesToEncrypt = ASCIIEncoding.ASCII.GetBytes(stringToEncrypt);
    //RijndaelManaged uses AES and defaults to CBC mode
    RijndaelManaged rij = new RijndaelManaged();
    rij.KeySize = 128;
    ICryptoTransform encryptor = rij.CreateEncryptor(
                     Convert.FromBase64String("7inEMafSQqaSANhMe92Gdw=="), initializationVectorBytes );
    byte[] encryptedBytes = encryptor.TransformFinalBlock(bytesToEncrypt, 0, bytesToEncrypt.Length);

    Hello...
    I've come up with this source, based on the examples given out there
    but, the ultimate output is will be an URL that'll be submitted as request.
    Looks like the data length is very high (as I get some error from the
    server, when I send the request url).
    Just wondering how do I make this code to do the same thing as given
    in the C# code above.
    Any help appreciated.
    Thanks,
    RK.
    private static String getEncryptedLogonData() throws Exception {
              String userDataToEncrypt = "Text";          
              return encrypt(userDataToEncrypt, getIV());;
         public static String encrypt(String text, byte[] iv) throws Exception {
              //Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
              Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
              //setup key
              byte[] keyBytes = new byte[16];
              int len = iv.length;
              if (len > keyBytes.length)
                   len = keyBytes.length;
              System.arraycopy(iv, 0, keyBytes, 0, len);
              SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");
              //the below may make this less secure, hard code byte array the IV in
              // both java and .net clients
              IvParameterSpec ivSpec = new IvParameterSpec(keyBytes);
              cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec);
              byte[] results = cipher.doFinal(text.getBytes("UTF-8"));
              BASE64Encoder encoder = new BASE64Encoder();
              return encoder.encode(results);
         private static byte[] getIV() {
              byte[] iv = new byte[16];
              Random r = new Random();
              r.nextBytes(iv);
              return iv;
         }

  • Code for a simple line break?

    Anyone know the syntax for a line break for data that is
    being displayed in notepad file:
    <CFCONTENT type="application/txt">
    <CFOUTPUT
    QUERY="getLines">#pccn##plisn##data##card#(need a line break
    here)</CFOUTPUT>

    Ken F. wrote:
    > Anyone know the syntax for a line break for data that is
    being displayed in
    > notepad file:
    >
    > <CFCONTENT type="application/txt">
    > <CFOUTPUT
    QUERY="getLines">#pccn##plisn##data##card#(need a line break
    > here)</CFOUTPUT>
    >
    #chr(13)##chr(10)# <!--- I.E. ASCII Codes for line break
    and carriage
    return. --->

  • 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

  • I Need Java code for following Algorithm

    * I Need Java code for following algorithm. Kindly any one help.
    1. Read the contents (ideas and its corresponding scores) from two files named as 'a' and 'b'.
    2. Stored the file 'a' contents in array a[].
    3. Stored the file 'b' contents in array b[].
    4. compare both files like
    if(a.equals(b[j])
    Writing the common idea and add the score from file 'a' and 'b'.
    else
    write the uncommon idea and its score..
    For example :
    Form Agents.txt
    action,65
    architecture,85
    eco-,15
    essay,30
    form,85
    form,85
    link,40
    tangent,25
    Form Agents1.txt
    Black holes,69
    essay,78
    Herewith i have above mentioned two files named as Form Agents and Form Agents1.
    Form Agents has eight fields
    Form Agents1 has two fields
    --> 'essay' is common in two files, so store the idea 'essay' and add the score from Form Agents score is '30' and Form Agents1 has 78 (essay 108).
    Finally it stores idea in another file with uncommon fields also.
    Please help us.

    We have tried with following code.
    But we cant add the scores.
    For Example:
    Form Agents.txt --> has "essay,30"
    Form Agents1.txt --> has "essay,78"
    Result is: essay,108
    Finally it stores idea in another file with uncommon fields also.
    So Any one pls correct the following code.
    try
    DataOutputStream o1=new DataOutputStream(new
    FileOutputStream("C:\\Interfaces\\interfaces\\temp\\BlackBoard\\My Design
    World\\Project\\Material\\art\\System Agents\\Form Agents\\CandidateResponses\\Form
    Agents.txt"));
    //Reading the contents of the files
    BufferedReader br= new BufferedReader(new InputStreamReader(new
    FileInputStream("C:\\Interfaces\\interfaces\\temp\\BlackBoard\\My Design
    World\\Project\\Material\\art\\System Agents\\Form Agents\\Ideological\\Form
    Agents.txt")));
    BufferedReader br1= new BufferedReader(new InputStreamReader(new
    FileInputStream("C:\\Interfaces\\interfaces\\temp\\BlackBoard\\My Design
    World\\Project\\Material\\art\\System Agents\\Form Agents\\Related\\Form
    Agents.txt")));
    while((s=br.readLine())!=null)
    s1+=s+"\n";
    while((s2=br1.readLine())!=null)
    s3+=s2+"\n";
    int numTokens = 0;
    StringTokenizer st = new StringTokenizer(s1);
    String[] a = new String[10000];
    String[] br_n=new String[10000];
    int i=0;
    while (st.hasMoreTokens())
    s2 = st.nextToken();
    a=s2.substring(0,s2.length()-3);
    s6=s2.substring(s2.length()-2);
    br_n[i]=s6;
    i++;
    numTokens++;
    int numTokens1 = 0;
    StringTokenizer st1 = new StringTokenizer (s3);
    String[] b = new String[10000];
    String[] br1_n=new String[1000];
    int j=0;
    while (st1.hasMoreTokens())
    s4 = st1.nextToken();
    b[j]=s4.substring(0,s4.length()-3);
    s7=s4.substring(s4.length()-2);
    br1_n[j]=s7;
    j++;
    numTokens1++;
    int x=0;
    for(int m=0;m<a.length;m++)
    for(int n=0;n<b.length;n++)
    if(a[m].equalsIgnoreCase(b[n])){
    int sc=Integer.parseInt(br_n[m]);
         int sc1=Integer.parseInt(br1_n[n]);
    int score=sc+sc1;
         o.writeBytes(a[m]+","+score+"\n");
    break;
    else
    o.writeBytes(a[m]+","+br_n[m]+"\n");
    break;
    }catch(Exception e){}

  • Where to write code for i_step =0

    Hi,
    I have written code for variable i_step=0 in CMOD.
    I am not able to test the code.
    Could you pls tell us, how to test the code and when this code will be populated.
    Where do i need to set break point , to see the code execution in debugging.
    Thanks

    You will write the logic using CMOD transaction only.You can set the break point the cmod code itself to check your code is working fine or not.
    I_STEP = 0
    The enhancement is not called from the variable screen. The call can come from the authorization check or from the Monitor. This is where you want to put the mod for populating the authorization object.
    Check the sample code
    case i_vnam.
      WHEN 'ZGMGRANT'.  "Query field name
        if i_step = 0.
    BREAK-POINT
          clear wa_ETRANGE.
    *     Gets all grants a user is able to see from ZTable,
    *     which is populated elsewhere 
          select grant_nbr
            from ZGMUSERGRANTS
            into corresponding fields of table it_ZGMUSERGRANTS
           where UNAME eq sy-uname.
    *     Populate Authorisation Object. In i_step 0
    *     E_T_RANGE is used to populate the authorisation object
          loop at it_ZGMUSERGRANTS into wa_ZGMUSERGRANTS.
            wa_ETRANGE-sign = 'I'.
            wa_ETRANGE-opt = 'EQ'.
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
              EXPORTING
                INPUT         = wa_ZGMUSERGRANTS-grant_nbr
             IMPORTING
               OUTPUT        = wa_ZGMUSERGRANTS-grant_nbr.
            wa_ETRANGE-low  = wa_ZGMUSERGRANTS-grant_nbr.
            append wa_ETRANGE to E_T_RANGE.
          endloop.
        endif.
      ENDCASE.

  • Streamlining the code for the button group with individual links and rollover imgs

    I am looking for a solution to streamline the code for the array of 20+  buttons located inside the scroll pane.
    I know I can make an array if all the buttons would have a unified code executable change, i.e. they would become larger and brighter.
    My problem is that each button represents an product image in the lights off stage, then of rollover it is a lights on stage so I have to import two images in the on and off stage and play around with the opacity.
    Additional problem is that each button has to ling to a different label.
    My question is: is it possible to unify the code if buttons have that much individuality or I have to make each one of them as in the example below.
    // makes a hand cursor appear over a mc acting as a button for all the buttons inside the scrollpnaeBckgrnd_mc.scrollpaneBckgrnd_btns_mc.
    MovieClip(mc_pane2.content).scrollpaneBckgrnd_mc.scrollpaneBckgrnd_btns_mc.buttonMode = true;
    MovieClip(mc_pane2.content).scrollpaneBckgrnd_mc.scrollpaneBckgrnd_btns_mc.useHandCursor = true;
    ///////////////INDIVIDUAL BUTTONS
              MovieClip(mc_pane2.content).scrollpaneBckgrnd_mc.scrollpaneBckgrnd_btns_mc.FloraLyte _btn.FloraLyte_ON.alpha = 0;
                        var  FloraLyte_btn_Tween:TweenLite = TweenLite.to(MovieClip(mc_pane2.content).scrollpaneBckgrnd_mc.scrollpaneBckgrnd_btns_mc.F loraLyte_btn.FloraLyte_ON, .5, {alpha:1, paused:true});
                        MovieClip(mc_pane2.content).scrollpaneBckgrnd_mc.scrollpaneBckgrnd_btns_mc.Flor aLyte_btn.addEventListener(MouseEvent.ROLL_OVER, overHandler_FloraLyte_btn);
                        MovieClip(mc_pane2.content).scrollpaneBckgrnd_mc.scrollpaneBckgrnd_btns_mc.Flor aLyte_btn.addEventListener(MouseEvent.ROLL_OUT, outHandler_FloraLyte_btn);
            MovieClip(mc_pane2.content).scrollpaneBckgrnd_mc.scrollpaneBckgrnd_btns_mc.FloraLyte_btn. addEventListener(MouseEvent.CLICK, onClick_floralytePopUp);
                      function onClick_floralytePopUp(event:MouseEvent) :void {
                                            gotoAndPlay("floralytepp");
    function overHandler_FloraLyte_btn(e:MouseEvent):void{
             FloraLyte_btn_Tween.play();
             trace("you rolled over me");
    function outHandler_FloraLyte_btn(e:MouseEvent):void{
             FloraLyte_btn_Tween.reverse();
             trace("you rolled off me");
    MovieClip(mc_pane2.content).scrollpaneBckgrnd_mc.scrollpaneBckgrnd_btns_mc.FloraLytell_btn .FloraLytell_ON.alpha = 0;
                        var  myTween:TweenLite = TweenLite.to(MovieClip(mc_pane2.content).scrollpaneBckgrnd_mc.scrollpaneBckgrnd_btns_mc.F loraLytell_btn.FloraLytell_ON, .5, {alpha:1, paused:true});
                        MovieClip(mc_pane2.content).scrollpaneBckgrnd_mc.scrollpaneBckgrnd_btns_mc.Flor aLytell_btn.addEventListener(MouseEvent.ROLL_OVER, overHandler);
                        MovieClip(mc_pane2.content).scrollpaneBckgrnd_mc.scrollpaneBckgrnd_btns_mc.Flor aLytell_btn.addEventListener(MouseEvent.ROLL_OUT, outHandler);
            MovieClip(mc_pane2.content).scrollpaneBckgrnd_mc.scrollpaneBckgrnd_btns_mc.FloraLytell_bt n.addEventListener(MouseEvent.CLICK, onClick_floralytellPopUp);
                      function onClick_floralytellPopUp(event:MouseEvent) :void {
                                            gotoAndPlay("floralyte2pp");
              function overHandler(e:MouseEvent):void{
             myTween.play();
             trace("you rolled over me");
              function outHandler(e:MouseEvent):void{
             myTween.reverse();
             trace("you rolled off me");

    as ned suggested, plan your flow and code into it. here is one example:
    var buttonArray = [someButton, someOtherButton, aDifferentButton];
    for(var i = 0; i < buttonArray.length; i++){
         //get reference to county movieclip
         var mc = buttonArray[i];
         //then add listeners
         mc.addEventListener(MouseEvent.ROLL_OVER, overMe);
    function overMe(e:MouseEvent){
         var mc = e.target;
         switch(mc){
              case: someButton:
                       someOtherButton:   doThis();
                                                     break;
              case: aDifferentButton:     doThat();
                                                     break;
              default:                            //do nothing;
                                                     break;
    function doThis(){
         trace("do this")
    function doThat(){
         trace("do that")

  • Code for the Planning Application. On Click....

    Hey Guys,
    I have been searching for that one file that holds the logic for "*redirecting to a particular URL, on clicking a Planning aaplication via the Workspace*". So far I have not struck gold.
    Please help/suggest the file that could get me a break.
    Thanks,
    Sasi

    It does.
    I am trying to integrate IBM TAM with Hyperion, and at a point I am experienceing a wrong "redirection".
    On analyzing, the root cause was found to be the URL generated during the click of the Planning App.
    Hence updating the URL at the source would help resolve my issue.
    Do let me know if you are aware of where exactly I can find the code for redirection.
    Thanks,
    Sasi

  • Hello sir,i need labview code for a code which is written in matlab,latter one is attached with this message.

    hello sir,i need labview code for a code which is written in matlab...
    clc;
    close all;
    clear all;
    Ez= zeros(1,200);
    Hy=zeros(1,200);
    Ca=1;
    Cb=.4519;
    n=1;
    while(n<1500)
    for k = 2:200
    Ez(k)=Ez(k) + Cb*(Hy(k)-Hy(k-1));
    end
    Ez(1)=1;
    for k=1:199
    Hy(k)=Hy(k)+Cb*(Ez(k+1)-Ez(k));
    end
    plot(Ez,'b')
    hold on
    plot(Hy,'r')
    hold off
    pause(0.001);
    n=n+1;
    end
    thanku

    Well, this code is quite trivial and if you have to learn LabVIEW anyway, you might as well try to implement it.
    A few things to remember:
    The first array element in LabVIEW has index #0, while in matlab it has index #1, so everything dealing with array indices needs to be adjusted slightly.
    The zeroes function equivalent is "initialize array".
    Keep the array in a shift register as you update elements.
    use FOR loops.
    Use one of the graphs to display the data.
    LabVIEW Champion . Do more with less code and in less time .

  • Sample code for connect to database

    Hi
    like to know if there is any sample code for me to follow through to connect to database using ODBC.
    I am currently writing a program in visual c++.
    like to know how to connect database to store image in the database
    using visual c++ code.....
    hope that is not too difficult.

    in JSTL pratical guide for JSP programmers by Sue Spielman
    <sql:setDataSource var="datasource"
    driver="org.gjt.mm.mysql.driver"
    url="jdbc:mysql://localhost/db"
    user="guest"
    password="guest" />
    <sql:query datasource="${datasource}...
    <html>
    <head>
    <title>
    Display Results
    </title>
    </head>
    <body>
    <c:catch var="sqlError">
    <sql:query var="bookList" dataSource="${datasource}">
         SELECT * FROM books WHERE title LIKE 'J%' ORDER BY author
    </sql:query>
    </c:catch>
    <c:if test="${not empty sqlError}" >
    Make sure you have already run the databaseinit.jsp file
    </c:if>
    <h2>Listing all books that start with a 'J', ordered by author</h2>
    <br>
    <table>
    <th>Title</th>
    <th>Author</th>
    <c:forEach var="book" items="${bookList.rows}">
         <tr>
              <td><c:out value="${book.title}" /></td>
              <td><c:out value="${book.author}" /></td>
         </tr>
    </c:forEach>
    </table>
    </table>
    <h2>Show using choose/when/otherwise conditional to display results</h2>
    <table>
    <tr><th>Title</th></tr>
    <c:forEach var="book" varStatus="current" items="${bookList.rows}">
    <tr>
    <c:choose>
         <c:when test="${current.first}" >
              <td><font color="#0000FF"><c:out value="${book.title}"/></font></td>
         </c:when>
         <c:when test="${current.count % 2 == 1 }" >
              <td><font color="#FF0000"><c:out value="${book.title}"/></font></td>
         </c:when>
         <c:otherwise>
              <td><c:out value="${book.title}"/></td>
         </c:otherwise>
    </c:choose>
    </tr>
    </c:forEach>
    </table>
    </body>
    </html>

  • Checking code for SAP USER EXIT

    we have enhanced SAP given data-source 2LIS_XX_XXXXX, there are hard coded user exits for this extractor. How to debug the code for enhancements?
    I know we enhance data-source in CMOD....SAPLRSAP001 (transactional data)....SAPLRSAP002(attributes)

    Hi Monica,
    There are many ways to debug the code if you wish to enhance the DataSource. In RSA3 you can do that by clicking Debug mode option. This is already been suggested by Srini.
    I would like to give you another way to do so.
    If you want to enhance the Transcational data then you need to choose EXIT_SAPLRSAP_001 component of RSAP001 enhancement. It has 4 component for master data( Text, hierarchy...etc).
    This is a function module enhancement. If you goto the source code of the function module, you will find an include program i.e. ZXRSAU01. double click on this program which will take you to the body of the program. This is the place where you need to write code.
    here you need to write the code as follows.
    case i_datasource.
    when '2LIS_XX_XXXXX'.
    Now here you can set a break point. This can be soft or hardcoded break point if you need to debug.
    Better Hardcode it. Write
    BREAK-POINT or BREAK username.
    Now when you execute the DS through RSA3, The program will stop here. The data extracted from DS will be available in an internal table C_T_DATA. Now you can enhance this by writing code. Again you can debug by pressing F5 or F6. This is as usual the way you debug an ABAP program.
    Hope this helps. If you need any further help contact at [email protected]
    Give reward point if you're satisfied.
    Happy debugging....
    cheers,
    Message was edited by: tapan tripathy

Maybe you are looking for

  • Mail goes to wrong box

    My incoming mail automtically goes to a deleted messages folder without going to my inbox. I obviously have clicked the wrong button, but I can't seem to figure it out. Any ideas would be appreciated. Thanks.

  • Problem Activating Mappings in the IR

    Hola Everyone! I'm having problems when trying to activate mappings in the Integration Repository.  Here's what I get: #4 13:57:14 ERROR com.sap.aii.utilxi.swing.toolkit.ExceptionDialog: Throwable Thrown: MESSAGE ID: com.sap.aii.ib.server.oa.rb_all.C

  • Preview app doesn't display hyperlinks

    PDFs when opened in Apple's Preview App do not work with hyperlinks (including mailto:s). We've tried with various work flows from both windows apps, Apple's 'print pdf', Acrobat Pro. Other apps work fine: e.g. Adobe Reader, Safari. I'm surprised not

  • Rebate accruals error

    Hi experts, I have a sceanrio where we upload a file using Z T.code. file conatining the Rebate Agrement number and Material No and the amount for Reabte accrual adjustments. For a Reabte agreement type we get below error Rebate Doc Value exceeds ope

  • How do I move songs from my iPod nano to my music library?

    I have an iPOD Nano that preceeds my purchases of iPad and iPhone devices.  Some music on my Nano is not in my current music library, probably because older PC's have crashed and in the process, some of the songs never made the transition into my com