Re: Request for suggestions re: architecture of IntraNet/Socket app[s]
- From: "Paul Nichols [TeamB]" <paul@xxxxxxxx>
- Date: Tue, 16 Oct 2007 00:17:50 -0400
Clay Shannon wrote:
I agree, but that's what the Powers That Be/Deciders are requiring (a browser-based app)Clay,
You do not need to use an exe, applet, or definitely not ActiveX (talk about a security hole), to accomplish what you want to do. It really doesn't matter what technology on the backend what you use either.
The large unknown here is the MOM protocol that is being used for the messaging from system to system. I cannot imagine needing to provide RTI (real time information) for every user for every transaction occurring in milliseconds. Since I do not know if all users have access to every other users data, I could be wrong about this.
If users only need real time access to the data that they have access to or that they control, then a Session object could be used to poll users based upon access to their data pools of access.
Your Ajax routine could be used to call an ISAPI dll from the browser, using a timer. This is not a really hard thing to do. What I do not know, is how much control you have over the MOM system and how it will be configured. Let's assume however, that for arguments sake, you have tp update from the server every second. The following is the Java code and JavaScript to make this work. I will use the server's clock function as an example. Please note whether you use Delphi or Java, or C#, or whatever on the server is immaterial, I am better now with Java than Delphi, so I can do this quicker in Java (do not IIS to test with on Linux either :))
Here is the Simple Java Servlet
/*
* ServerRefresh.java
*
* Created on Oct 15, 2007, 10:43:05 PM
*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.clc.examples;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class ServerRefresh extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
int hrs=0;
int min=0;
int secs=0;
int milSecs=0;
try {
String name=request.getParameter("name");
//Calendar cal=Calendar.getInstance();
// hrs=cal.HOUR;
// min=cal.MINUTE;
// secs=cal.SECOND;
Date d= new Date();
out.println(d.toString());
} finally {
out.close();
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*/
public String getServletInfo() {
return "Short description";
}
// </editor-fold>
}
And here is the HTML with the Java Script Timer
<%--
Document : index
Created on : Oct 15, 2007, 9:12:04 PM
Author : paul
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Update Page</title>
<script language="javascript">
var _ajaxObj; //This is the HTTPXML Object
//Get Server Time is a callback method for updating browser
function getServerTime(){
var x = 10;
var y = 10;
x = x-y;
// document.frm.clock.value = x;
//Create XMLHttpRequest for MS based browsers
if(navigator.appName.indexOf("Explorer")>1){
//Create ActiveX HTTPObject
_ajaxObj= new ActiveXObject("Microsoft.XMLHTTP");
}
else {
//Create XMLHttpRequest for non MS based browsers
if(! window.ActiveXObject){
_ajaxObj=new XMLHttpRequest();
//_ajaxObj.overrideMimeType('text/xml');
}
}
//Call the Server Side function
_ajaxObj.open("GET","doRefresh?name=value",true);
_ajaxObj.onreadystatechange=makeServerRequest;
_ajaxObj.send(null);
//Change the time by changing the wait--default 1000
setTimeout("getServerTime()", 1000);
}
//This function displays the results from server call.
//Uncomment the first line to show wait state
function makeServerRequest(){
// if(_ajaxObj.readyState==1){
// var load="<span style=\"font-family:Arial,Geneva,Verdana,Sans-Serif; "+
// "color:#FF6600; font-weight:bold; font-size:10pt;\">Loading.. </span>";
// document.getElementById("waitCursor").innerHTML=load;
// }
if (_ajaxObj.readyState==4){
var resp=_ajaxObj.responseText;
if(navigator.appName.indexOf("Explorer")>1)
document.getElementById("serverData").innerText=resp;
else
document.getElementById("serverData").innerHTML=resp;
}
}
</script>
</head>
<body onload="getServerTime();">
<p align="center">
<h3 align="center" style="color:blue;">This form will show updated time from server using AJAX</h3>
<div id="waitCursor">
</div>
<table style="font-family:Vedana,Geneva, Sans-Serif; font-size:10pt; color:navy; vertical-align:top; width:760px;"
cellpadding="2" cellspacing="2" align="center">
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="2" style="font-family:Arial,Helvetica,Geneva,Sas-Serif; font-size:18pt; color:navy;font-declaration:underline;" align="center">
<b> My updated JSP, could be HTML as well</b>
<br/>
<br/>
</td>
</tr>
<tr>
<td align="right"> <b>Name:</b> </td>
<td style="font-family:Arial,Helvetica,Geneva,Sas-Serif; font-size:12pt; color:navy;">Paul Nichols</td>
</tr>
<tr>
<td align="right"><b>Created For:</b></td>
<td style="font-family:Arial,Helvetica,Geneva,Sas-Serif; font-size:12pt; color:navy;">Delphi Non Tech Forum </td>
</tr>
<tr>
<td style="font-family:Arial,Helvetica,Geneva,Sas-Serif; font-size:13pt; color:navy;"colspan="2" align="center">
<br/>
<b>An example of updating data through AJAX </b>
<br/>
<br/>
</td>
</tr>
<tr>
<td align="right"><b>Look here for dynamic updates:</b></td>
<td>
<div id="serverData" style="font-family:Arial,Helvetica,Geneva,Sas-Serif; font-size:12pt; color:maroon;">
Time Updates
</div>
</td>
</tr>
</table>
</p>
</body>
</html>
You can make the <div id="serverData"></div> return anything you want.
Hope this helps!!
.
- References:
- Request for suggestions re: architecture of IntraNet/Socket app[s]
- From: Clay Shannon
- Re: Request for suggestions re: architecture of IntraNet/Socket app[s]
- From: Alessandro Federici
- Re: Request for suggestions re: architecture of IntraNet/Socket app[s]
- From: Clay Shannon
- Request for suggestions re: architecture of IntraNet/Socket app[s]
- Prev by Date: Re: ISO Available
- Next by Date: Re: Limited Kylix Open Source
- Previous by thread: Re: Request for suggestions re: architecture of IntraNet/Socket app[s]
- Next by thread: Re: Request for suggestions re: architecture of IntraNet/Socket app[s]
- Index(es):
Relevant Pages
|