Source Code Cross Referenced for AppletUtils.java in  » J2EE » Enhydra-Application-Framework » com » lutris » appserver » server » httpPresentation » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » Enhydra Application Framework » com.lutris.appserver.server.httpPresentation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Enhydra Java Application Server Project
003:         * 
004:         * The contents of this file are subject to the Enhydra Public License
005:         * Version 1.1 (the "License"); you may not use this file except in
006:         * compliance with the License. You may obtain a copy of the License on
007:         * the Enhydra web site ( http://www.enhydra.org/ ).
008:         * 
009:         * Software distributed under the License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 
011:         * the License for the specific terms governing rights and limitations
012:         * under the License.
013:         * 
014:         * The Initial Developer of the Enhydra Application Server is Lutris
015:         * Technologies, Inc. The Enhydra Application Server and portions created
016:         * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017:         * All Rights Reserved.
018:         * 
019:         * Contributor(s):
020:         * 
021:         * $Id: AppletUtils.java,v 1.2 2006-06-15 13:40:47 sinisa Exp $
022:         */
023:
024:        package com.lutris.appserver.server.httpPresentation;
025:
026:        import com.lutris.applet.LBSConnection;
027:
028:        /**
029:         *   This is the counterpart to com.lutris.applet.LBSConnection. This class
030:         *   creates <APPLET ...> tags with extra initialization parameters.
031:         *   LBSConnection reads those extra initialization parameters and uses them
032:         *   to establish a connection back to the Mutliserver.
033:         *   This file is used by a presentation object, while LBSConnection is 
034:         *   included in the applet's jar file or classes directory. This way it
035:         *   does not need to include the com.lutris.appserver.server.* classes.
036:         *
037:         * @see com.lutris.applet.LBSConnection.
038:         */
039:        public class AppletUtils {
040:
041:            /**
042:             * Private constructor to prevent instantiation; use the static methods.
043:             */
044:            private AppletUtils() {
045:            }
046:
047:            /**
048:             *
049:             *  This assumes that if cookies are being used, the name of the cookie
050:             *  is the application name. This is true if the StandardApplication is
051:             *  being used.
052:             *
053:             *  @param comms
054:             *   HTTP communications object. Contains objects and interfaces to read
055:             *   the request and send a response.
056:             *  @param targetURL
057:             *   The URL of the presentation object the applet should connect to.
058:             *   For example: "/package/Presentaion.po". The server name and
059:             *   presentation path will automatically be added.
060:             *  @param options
061:             *   A list of various applet options to be included in the applet tag.
062:             *   For example: "code=myApplet.class width=400 height=100". These
063:             *   three are required options.
064:             *  @param parameterNames
065:             *   An array of parameter names, for example: {"X", "Y", "maxIterations"}.
066:             *   This is optional.
067:             *  @param parameterValues
068:             *   An array of parameter values, for example: {"24", "19", "2000"}.
069:             *   Either this an <CODE>parameterNames</CODE> must be null, or they
070:             *   must have the same number of elements. <CODE>parameterNames[i]</CODE>
071:             *   is matched up with <CODE>parameterValues[i]</CODE>.
072:             *   This is optional.
073:             *  @param alternateHtml Any HTML to display if the browser does not
074:             *   support applets. This is optional, and may be null.
075:             *  @return  
076:             *   A string of the form "<APPLET code=... > <PARAM NAME=... VALUE=...>
077:             *   .....   </APPLET>".
078:             */
079:            public static String createAppletTag(HttpPresentationComms comms,
080:                    String targetURL, String options, String[] parameterNames,
081:                    String[] parameterValues, String alternateHtml) {
082:                /*
083:                 * Check input.
084:                 */
085:                if (targetURL == null)
086:                    targetURL = ""; // This is an error, but ignore for now.
087:                if (options == null)
088:                    options = ""; // This is an error, but ignore for now.
089:                if (alternateHtml == null)
090:                    alternateHtml = "";
091:                /*
092:                 *  Start off with the APPLET tag and the options.
093:                 */
094:                StringBuffer result = new StringBuffer();
095:                result.append("\n<APPLET ");
096:                result.append(options);
097:                result.append(">\n");
098:                /*
099:                 *  Add any user-supplied parameters.
100:                 */
101:                if ((parameterNames != null) && (parameterValues != null))
102:                    for (int i = 0; i < parameterNames.length; i++) {
103:                        result.append("<PARAM NAME=");
104:                        result.append(parameterNames[i]);
105:                        result.append(" VALUE=");
106:                        result.append(parameterValues[i]);
107:                        result.append(">\n");
108:                    }
109:                /*
110:                 *  Figure out the cookie settings.
111:                 */
112:                String cookieName = comms.application.getName();
113:                String cookieValue = comms.session.getSessionKey();
114:                /*
115:                 *  Build up a complete URL for the target.
116:                 */
117:                String server = comms.request.getServerName();
118:                int port = comms.request.getServerPort();
119:                String pp = "/";
120:                try {
121:                    pp = comms.request.getApplicationPath();
122:                } catch (HttpPresentationException e) {
123:                }
124:                if (!pp.startsWith("/"))
125:                    pp = "/" + pp;
126:                if (!pp.endsWith("/"))
127:                    pp = pp + "/";
128:                if (targetURL.startsWith("/"))
129:                    targetURL = targetURL.substring(1);
130:                String fullURL = "http://" + server;
131:                if (port != 80)
132:                    fullURL += ":" + port;
133:                fullURL += pp + targetURL;
134:                /*
135:                 *  Add the target and the session cookie parameter. 
136:                 *  The applet will need this
137:                 *  when it issues requests back to the server, to access the current
138:                 *  session.
139:                 *  See StandardAppUtil.bindSessionToClient().
140:                 */
141:                result.append("<PARAM NAME=");
142:                result.append(LBSConnection.nameParamName);
143:                result.append(" VALUE=");
144:                result.append(cookieName);
145:                result.append(">\n");
146:                result.append("<PARAM NAME=");
147:                result.append(LBSConnection.valueParamName);
148:                result.append(" VALUE=");
149:                result.append(cookieValue);
150:                result.append(">\n");
151:                result.append("<PARAM NAME=");
152:                result.append(LBSConnection.targetParamName);
153:                result.append(" VALUE=");
154:                result.append(fullURL);
155:                result.append(">\n");
156:                /*
157:                 *  Finish off with the alternate html, then close the tag.
158:                 */
159:                result.append(alternateHtml);
160:                result.append("\n</APPLET>\n");
161:                /*
162:                 *  All done.
163:                 */
164:                return result.toString();
165:            }
166:
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.