Communication Applet - Servlet
Hello,
I'm trying to do a communication Applet - Servlet.
When i'm typing in my browser internet explorer
http://pcsm1:8080/servlet/MyServlet
My servlet is invoqued perfectly and i see the good message in the prompt ms-dos (cf MS-DOS PROMPT : MESSAGE OF THE SERVLET!)
But when i'm trying with my applet, i have a security exception : cannot access "pcsm1":8080
SERVLET :
public class MyServlet extends HttpServlet
public void init(ServletConfig config)
System.out.println("Servlet Init");
public void doGet(HttpServletRequest request,HttpServletResponse response)
ObjectOutputStream outputToApplet;
long data=69;
try
outputToApplet = new ObjectOutputStream (response.getOutputStream()); System.out.println("Sending data to applet...");
outputToApplet.writeLong(data);
outputToApplet.flush();
outputToApplet.close();
System.out.println("Data transmission complete.");
catch (IOException e)
public void doPost(HttpServletRequest request,HttpServletResponse response)
APPLET :
public class MyApplet extends Applet
public void init()
try
URL url = new URL("http://pcsm1:8080/servlet/MyServlet");
or
URL url = new URL(getCodeBase(),"http://pcsm1:8080/servlet/MyServlet");
URLConnection servletConnection = url.openConnection();
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
servletConnection.setUseCaches (false);
servletConnection.setDefaultUseCaches (false);
servletConnection.setRequestProperty("Content-type","application/octet-stream");
ObjectInputStream inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
data = inputFromServlet.readLong();
inputFromServlet.close();
catch (Exception e)
MS-DOS PROMPT : MESSAGE OF THE SERVLET
when caller is internet explorer
C:\Servlet\bin>servletrunner -d "c:\servlet\bin"
servletrunner starting with settings:
port = 8080
backlog = 50
max handlers = 100
timeout = 5000
servlet dir = c:\servlet\bin
document dir = .\examples
servlet propfile = c:\servlet\bin\servlet.properties
Servlet Init
Sending data to applet...
Data transmission complete.
What can i do to avoid my security exception problem?
Very thanks...
Are MyServlet and the HTML page hosting MyApplet being served from the same server (i.e., pcsm1:8080)? If not, this is a violation of one of the security constraints placed on unsigned applets.
If the above scenario is the case, there are three options to overcome:
1) Create a signed applet
2) Move the HTML/Applet to the same server as the Servlet
3) On the server serving the HTML/Applet, create a "proxy" servlet to which the applet can connect and which will in turn contact MyServlet (through HttpURLConnection)
Similar Messages
-
Applet/servlet communication for byte transmission
Hello all !
I wrote an applet to transfer binary file from web servlet (running under Tomcat 5.5) to a client (it's a signed applet) but I have a problem of interpretation of byte during transmission.
the code of the servlet is :
response.setContentType("application/octet-stream");
ServletOutputStream sos = response.getOutputStream();
FileInputStream fis = new FileInputStream(new File(
"C:\\WINDOWS\\system32\\setup.bmp"));
byte[] b = new byte[1024];
int nbRead = 1;
while (nbRead > 0) {
nbRead = fis.read(b);
System.out.println("octets lus = " + nbRead);
sos.write(b, 0, nbRead-1);
fis.close();
sos.close();et le code de l'applet qui appelle cette servlet est :
URL selicPortal = null;
try {
selicPortal = new URL(
"http://localhost:8080/AppletTest/servlet/FileManipulation");
} catch (MalformedURLException e) {
e.printStackTrace();
URLConnection selicConnection = null;
try {
selicConnection = selicPortal.openConnection();
} catch (IOException e) {
e.printStackTrace();
selicConnection.setDoInput(true);
selicConnection.setDoOutput(true);
selicConnection.setUseCaches(false);
selicConnection.setRequestProperty("Content-Type",
"application/octet-stream");
try {
InputStream in = selicConnection.getInputStream();
FileOutputStream fos = new FileOutputStream(new File(tempDir
+ "\\toto.bmp"));
byte[] b = new byte[1024];
int nbRead = in.read(b);
while (nbRead > 0) {
fos.write(b);
in.close();
fos.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}the file dowloaded is broken. it seems that bytes 01 00 or 00 01 are not correctly process.
Some ideas to help me please ?hi,
have you solved this issue.. please post me the code since i m also doing the applet/servlet communication and can use your code as reference.
how to read the content placed in the urlConnection stream in the servlet
Below is my code in applet
public void upload(byte[] imageByte)
URL uploadURL=null;
try
uploadURL=new URL("<url>");
URLConnection urlConnection=uploadURL.openConnection();
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
urlConnection.setUseCaches(false);
urlConnection.setRequestProperty("Content-type","application/octet-stream");
urlConnection.setRequestProperty("Content-length",""+imageByte.length);
OutputStream outStream=urlConnection.getOutputStream();
outStream.write(imageByte);
outStream.close();
catch(MalformedURLException ex)
catch(IOException ex)
How can i read the byte sent on the outstream (in above code) in the servlet.
Thanks,
Mclaren -
Asynchronous applet-servlet communication
Hi all,
I am trying to implement asynchronous applet-servlet communication and need your help. Anything would help(I tried with synchronous applet-servlet communication but doesn't solve my problem).
Thanks,http://java.sun.com/docs/books/tutorial/networking/index.html
You can open a socket connection. Bother the client and the server
can have separate threads for reading and writing and that you gives you
asynchronous communication. Later, if you think the server is generating
too many threads and not scaling, you can use features of .java.nio to
make it more scalable:
java.nio.channels -
Is there a good advanced review on applet-servlet communication
I am working on a web application and unfortunately experiencing a lot of trouble trying to use an applet as front end which interacts with a couple of servlets running on Tomcat. I need to get data from one servlet and send data to another.
There is a lot of messages posted in this and other forums about how to do this, but none of them got a response pointing to a useful advanced reference on this subject. I have reviewed some of the references given, but couldn't find a thorough detailed advanced reference on applet-servlet communication. For this I mean an exhaustive explanation of the mechanism of communication and when and when is neccesary to use each of the multiple configuration possibilities regarding content-type, message-length, request-method, connection settings, and so on.
Would anybody be so kind to show me the right direction? As I read the (literally) hundreds of messages posted on this topic, I see this info as widely useful. Most of the topic tracks ends on void or with painful no-way sentences, and maybe many people is avoiding Java technology on web application because of this problem (development delays can abort a project).This sample chapter in Java developers' guide to Servlets and Jsp focuses on Applet-Servlet communication, is a pretty good one, and is free :
http://www.javaranch.com/bunkhouse/samps/2809ch12.pdf
As to an exhaustive & complete guide that covers absolutely everything, I may be wrong but I doubt you'll find anything like that...unless there is a book somewhere dedicated to the subject. -
Applet-servlet communication, object serialization, problem
hi,
I encountered a problem with tomcat 5.5. Grazing the whole web i didn't find any solution (some guys are having the same problem but they also got no useful hint up to now). The problem is as follows:
I try to build an applet-servlet communication using serialized objects. In my test scenario i write a serialized standard java object (e.g. a String object) onto the ObjectOutputStream of the applet/test-application (it doesn't matters wheter to use the first or the latter one for test cases) and the doPost method of the servlet reads the object from the ObjectInputStream. That works fine. But if i use customized objects (which should also work fine) the same code produces an classnotfound exception. When i try to read and cast the object:
TestMessage e = (TestMessage)objin.readObject();
java.lang.ClassNotFoundException: TestMessage
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1205)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
...That seems strange to me, because if i instantiate an object of the same customized class (TestMessage) in the servlet code, the webappclassloader doesn't have any problems loading and handling the class and the code works fine!
The class is located in the web-inf/classes directory of the application. I've already tried to put the class (with and without the package structure) into the common/classes and server/classes directory, but the exception stays the same (I've also tried to build a jar and put it in the appropriate lib directories).
I've also tried to catch a Throwable object in order to get information on the cause. But i get a "null" value (the docu says, that this will may be caused by an unknown error).
I've also inspected the log files intensively. But they gave me no hint. Until now I've spend a lot of time on searching and messing around but i always get this classnotfound exception.
I hope this is the right place to post this problem and i hope that there is anyone out there who can give me some hint on solving this problem.
Kindly regards,
Danielhi, thanks for the reply,
all my classes are in the web-inf/classes of the web-app and have an appropriate package structure. thus the TestMessage class is inside a package.
i tried some names for the testclass but it didn't matter. the exception stays the same. I also tried to put the jar in the common/lib but the problem stays.
Well the problem with loaded classes: As i mentioned in the post above i can instantiate an object of TestMessage in the code without any problems (so the classloader of my webapp should know the class!!)
only when reading from the objectinputstream the classloader doesn't seem to know the class?? maybe theres a parent classloader resposible for that and doesn't know the class?
strange behaviour...
p.s. sending the same object from the servlet to the client works well
regards
daniel
Message was edited by:
theazazel -
Applet/Servlet communication - StreamCorruptedException
Hi, I'm having a problem when I try to connect to a servlet. I am using applet/servlet communication. The problem only occurs when I have lauched a crystal report via http in a new window.
After the report is launched if I try to hit my servlet I get the following error:
java.io.CorruptedStreamException: invalid stream header
Not all crystal reports I launch cause this behavior but I can see nothing in the url I use to launch the report that is out of place or different than other reports.
APPLET-SERVLET CONNECTION
try {
StringBuffer path = new StringBuffer();
path.append(ip);
path.append("servlet/DatabaseServlet?");
path.append("option=getRecords&query=").append(URLEncoder.encode(query,"UTF-8"));
URL url = new URL(path.toString());
URLConnection servletConnection = url.openConnection();
servletConnection.setUseCaches(false);
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
servletConnection.setRequestProperty("Content-Type", "application/x-java-serialized-object");
ObjectInputStream inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
rc = (RecordCollection) inputFromServlet.readObject();
inputFromServlet.close();
} catch (Exception e) {
e.printStackTrace();
SERVLET CODE
Forwards to doPost
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("session id: " + request.getSession().getId());
this.doPost(request, response);
LAUNCHING REPORT FROM APPLET
try {
String launchURL = host + directory + report + "?promptOnRefresh=0"+ "&" +
authentication + "&" + key + "&" + startPeriods + "&" + reportYears + "&" + reportTitle + "&" endPeriods "&" + locations + "&" + reportPeriod + "&" + fiscalWeek + "&" + fiscalYear + "&" +time;
context.showDocument(new URL(launchURL), "_blank");
} catch (Exception ex) {
ex.printStackTrace();
SAMPLE URL THAT CAUSES PROBLEM
http://localhost:113/Reports/OpenToBuy_3.class?promptOnRefresh=0&user0=rpuser&password0=er34sw1&[email protected]=rpuser&[email protected]=er34sw1&user0@sub2=rpuser&[email protected]=er34sw1&promptex-key="L","L1","ALL"&promptex-start="1"&promptex-years="2004","2004"&promptex-title="Report Title"&promptex-end="1"&promptex-locs="01","03","04","05"&promptex-period="Feb 2004 [04-01]"&promptex-cw="1"&promptex-cy="2004"&promptex-time=-2-52728"
Everything works fine until I launch this report then I can no longer get data from my servlet. I thought the URL lenght for the report might be the problem but I lauch a report with a URL longer than the problem one and there I don't get the errors after. When I try to connect to the servlet the println statement in the doGet method of my servlet doesn't get printed so it's not even making it inside that method in the servlet.
Anyone have any idea what could be causing this? Anyone have any ideas what would be causing this? I'm really stumped.I've seen this problem before. Because your accessing a complete URL (ie http://<host>:<port>/xxx), you are actually creating a new session. Whenever the applet opens a connection to a servlet it is running on it's own session not the same as the JSP. This is rather obvious since the Page and Applet are separate entities.
Try sending authentication with the url. I think the syntax is:
username:password@http://localhost/xxx
However I'm not sure how well this might work for Tomcat. As for Java it may try and throw a MalformedURLException I would have to test it first - it's been a long time since I used this technique!
Wish I could be more help,
Anthony -
Problem in Applet Servlet communication in cluster
Our new production server has been configured with
clusters very recently.The application is running fine if and only if one instance
of weblogic is running.The application has two applets that communicate through a
servlet and the servlet is hosted by both the WL servers in the cluster.
Please consider the following scenario :
1. JSP#1(having embedded tag for Applet#1) is served by, say, WLInstance#1.
2. JSP#2(having embedded tag for Applet#2) is served by, say, WLInstance#2.
3. Applet#1 is loaded by BrowserInstance#1.
4. Applet#2 is loaded by BrowserInstance#2.
The way I understand applet-servlet communication is as follows :
The servlets are invoked through the url-pattern specified in web.xml - if the applet
is making use of a certain url-pattern that is mapped to servlet, then the call from
that applet will
eventually invoke a servlet on any of the two instances till a session is established,
at which point all subsequent requests from the same browser window/frame will go
to the servlet hosted on the instance where the http session was created.
(Please correct me, if I am wrong.)
So, Applet#1 will always talk to the servlet hosted by WLInstance#1 and Applet#2
will always talk to the servlet hosted by WLInstance#2.
In our case, the servlet is maintaining data structures to store all the messages
sent by diffterent instances of Applets.
The applets periodically polls the messages from those data structures.Once the messages
are polled, those are deleted from
the data structures.
As there are two different instances of the servlet, Applet#1 never gets messages
posted by Applet#2.
Is there a way to make this data structure global to both the servlet instances?
Thanks and best regards,
Subir Das
"Subir Das" <[email protected]> wrote:
>So, Applet#1 will always talk to the servlet hosted by WLInstance#1 and
>Applet#2
>will always talk to the servlet hosted by WLInstance#2.
This statement is not entirely true.
Suppose WLInstance#1 were to be brought down (for whatever reason), Applet#1 will
then talk to servlet hosted by WLInstance#2.
Server pinning could be modified by different load balancing algorithms, configurable
via containers (or hardware).
So don't count on which servlet instance your applet is going to be served by.
Instead consider to give a second look into the design of the servlet data structure
(object):
1.Read from data store, if it has been persisted.
2.If the data is client related then consider sticking the data into session, which
would then replicate to other WL instances.
3.Stateless EJB in a cluster ? Don' know much about this(yet).
My 2 cents..Good luck.
Rama
-
Applet Servlet communication compiles but does not communicate
Hi,
I have a applet which has a button named A. By clicking the button, the applet passes the letter A to the servlet. The servlet in turn accesses an Oracle database and retrieves the name corresponding to letter A from a table (name is Andy in the present case). The servlet interacts with the databse via a simple stored procedure and uses its output parameter to display the name Andy back in the applet.
Both the applet and servlet codes have compiled fine(servlet code compiled with -classpath option to servlet jar using a TOMCAT). However, on clicking button A in the applet, I do not get the name Andy.
Any help/suggestion in resolution of this is highly appreciated. Thanks in advance.
HTML CODE:
<html>
<center>
<applet code = "NameApplet.class" width = "600" height = "400">
</applet>
</center>
</html>
STORED PROCEDURE CODE:
procedure get_letter_description(
ac_letter IN CHAR,
as_letter_description OUT VARCHAR2) IS
BEGIN
SELECT letter_description INTO as_letter_description FROM letter WHERE letter =
ac_letter;
EXCEPTION
WHEN no_data_found THEN as_letter_description := 'No description available';
END get_letter_description;
APPLET CODE:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.*;
import java.io.*;
import java.net.*;
public class NameApplet extends Applet implements ActionListener
private TextField text;
private Button button1;
private String webServerStr = null;
private String hostName = "localhost";
private int port = 8080;
private String servletPath = "/examples/servlet/NameServlet?letter=";
private String letter;
public void init()
button1 = new Button("A");
button1.addActionListener(this);
add(button1);
text = new TextField(20);
add(text);
// get the host name and port of the applet's web server
URL hostURL = getCodeBase();
hostName = hostURL.getHost();
port = hostURL.getPort();
webServerStr = "http://" + hostName + ":" + port + servletPath;
public void actionPerformed(ActionEvent e)
if (e.getSource() == button1)
letter = "" + 'A';
private String getName(String letter){
String name = "" ;
try {
URL u = new URL(webServerStr + letter);
Object content = u.getContent();
name = content.toString();
} catch (Exception e) {
System.err.println("Error in getting name");
return name;
SERVLET CODE:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import java.util.Properties;
public class NameAppletServlet extends HttpServlet {
private static Connection conn = null;
private static final char DEFAULT_CHAR = 'A';
private static final char MIN_CHAR = 'A';
private static final char MAX_CHAR = 'G';
private static final String PROCEDURE_CALL
= "{call get_letter_description(?, ?)}";
protected void doGet( HttpServletRequest request,
HttpServletResponse response )
throws ServletException, IOException
handleHttpRequest(request, response);
protected void doPost( HttpServletRequest request,
HttpServletResponse response )
throws ServletException, IOException
handleHttpRequest(request, response);
protected void handleHttpRequest( HttpServletRequest request,
HttpServletResponse response )
throws ServletException, IOException
String phrase = null;
char letter = getLetter(request, DEFAULT_CHAR);
if (letter >= MIN_CHAR && letter <= MAX_CHAR) {
try {
name = getName(conn, letter);
} catch (SQLException se) {
String msg = "Unable to retrieve name from database.";
name = msg;
} else {
String msg = "Invalid letter '" + letter + "' requested.";
//throw new ServletException(msg);
phrase = msg;
response.setContentType("text/plain");
PrintWriter out = response.getWriter();
out.println(name);
private String getName(Connection conn, char letter)
throws SQLException
CallableStatement cstmt = conn.prepareCall(PROCEDURE_CALL);
cstmt.setString(1, String.valueOf(letter));
cstmt.registerOutParameter(2, Types.VARCHAR);
cstmt.execute();
String name = cstmt.getString(2);
cstmt.close();
return name;
private char getLetter(HttpServletRequest request, char defaultLetter) {
char letter = defaultLetter;
String letterString = request.getParameter("letter");
if (letterString!=null) {
letter = letterString.charAt(0);
return letter;
public void init(ServletConfig conf) throws ServletException {
super.init(conf);
String dbPropertyFile = getInitParameter("db.property.file");
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(
"jdbc:oracle:thin:myserver:1521:CDD",
"scott",
"tiger");
} catch (IOException ioe) {
throw new ServletException(
"Unable to init ReinforcementServlet: " + ioe.toString());
} catch (ClassNotFoundException cnfe) {
throw new ServletException(
"Unable to init ReinforcementServlet. Could not find driver: "
+ cnfe.toString());
} catch (SQLException se) {
throw new ServletException(
"Unable to init ReinforcementServlet. Error establishing"
+ " database connection: " + se.toString());
}Hi,
I am not able to understand by which method you are doing Applet-Servlet commuincation.
If you want to use Object Serialization method, plz.get the details from following URL.
http://www.j-nine.com/pubs/applet2servlet/
Ajay -
Communication between servlet & applet
Hello everybody,
Well, I have a problem with my applet/servlet system.
I Would like my applet to send some queries to the servlet.
However, I don't know how to link the applet with the servlet (the only way I know is to use "openConnection()", but I don't see how to incorporate my query in the URLConnection (in order to have one, I need openCOnnection, and once it's done, well, the doGet method has already be laucnh, without any parameter to read). In my case, the DoGet methods of the servlet is launched, and of course, the HTTPRequest is almost empty, seeing thath I don't see how to specify the differnets parameters.
Is thereany simple meaning to make the applet communicate this the servlet, sending strings, and receiving objects (I have already solve the problem of the sending of an object from the servlet to the applet, in the doGet method).
Thank you very much
C UIn the applet html include a servlet parameter.
<param
name="servlet"
value="/SqlServlet" />
In your applet open a connection to servlet.
InputStream in = null;
URLConnection conn = null;
URL url = null;
String servlet = getParameter("servlet");
url = new URL(servlet + "?sql=" + URLEncoder.encode(sql));
conn = url.openConnection();
in = conn.getInputStream(); -
Communicating applet with Servlets
Dear Friends,
I need to communicate Applet & Servlet.
Servlet should take the data from an wesite & it write the data
to a file . the applet should read the file . these action should take
automatically ( i.e updation )This is too large to tell you here (you should read it on thousands of other pages - see google). But I want to note that you should avoid reading files with applets. Applets should almost always run within their sandbox (security model) without accessing exetrnal resources. It should only have to access the server it originates from.
-
Communication between Applets & Servlets
How do you communicate in between Applets & Servlets ?
http://forum.java.sun.com/thread.jsp?forum=45&thread=525518&start=0&range=15#2519429
-
EOF exception during applet - servlet communication
I am developing a system for the US Gov't. This system currently
utilizes several applets which access corresponding servlets on
WebLogic. Seemingly, things went wrong for no apparent reason this
morning. When, trying to run our applets, WebLogic throws an exception:
"Caught EOFException in the stream header" These exceptions occur
everytime the servlet would open the input stream from the applet. What
makes things mind-boggling is that these applets/servlets were working
this morning, and suddenly now give these exceptions. The code for both
the applets and servlets has not been touched in weeks. Furthermore, i
tested even further by running WebLogic locally and running the applets
in our IDE (as applications) and the same results occur. I am running
WebLogic 5.1 SP6 on both the remote and local system and am utilizing
JDK 1.3 on both as well. The server is running on WinNT SP6 and locally
is Win2000 Pro SP1. These applets are critical to the entire system and
i am just totally baffled as to why something that was working fine one
day ago should all of the sudden spit up errors and exceptions.
If anyone can give me some insight as to what is going on, please let me
know.
Thank you,
Randy Strobel
[email protected]
Randy,
I don't know of any particular reasons why WebLogic would suddenly affect an
application in the manner that you describe. Start by figuring out where
the message comes from:
> "Caught EOFException in the stream header"
I assume that is in WebLogic's code, not yours? Figure out as close as
possible who is detecting this error condition. If it is in WebLogic's
code, you can ask support at BEA to tell you what it is complaining about
(i.e. what it is expecting to read).
You will have to post the exception trace here and it would help to see the
code that is causing the exception.
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com
+1.617.623.5782
WebLogic Consulting Available
"Randy Strobel" <[email protected]> wrote in message
news:[email protected]...
> I am developing a system for the US Gov't. This system currently
> utilizes several applets which access corresponding servlets on
> WebLogic. Seemingly, things went wrong for no apparent reason this
> morning. When, trying to run our applets, WebLogic throws an exception:
> "Caught EOFException in the stream header" These exceptions occur
> everytime the servlet would open the input stream from the applet. What
> makes things mind-boggling is that these applets/servlets were working
> this morning, and suddenly now give these exceptions. The code for both
> the applets and servlets has not been touched in weeks. Furthermore, i
> tested even further by running WebLogic locally and running the applets
> in our IDE (as applications) and the same results occur. I am running
> WebLogic 5.1 SP6 on both the remote and local system and am utilizing
> JDK 1.3 on both as well. The server is running on WinNT SP6 and locally
> is Win2000 Pro SP1. These applets are critical to the entire system and
> i am just totally baffled as to why something that was working fine one
> day ago should all of the sudden spit up errors and exceptions.
>
> If anyone can give me some insight as to what is going on, please let me
> know.
> Thank you,
> Randy Strobel
> [email protected]
>
>
-
Netscape problem with applet servlet communication
Netscape always seems to get in the way when you use applets, right?
I have a nice set of code from a book that shows how to do applet->servlet stuff.
But although I'm doing this all in the privacy of my own localhost Netscape immediately put a spanner in the works with a security exception and wouldn't let the servlet respond.
Anyone know what to do here.
The answer is to use Internet Explorer, possibly, but I'm in linux, and I can't get Opera to work with java yet.
Anyone got any ideas? Thanks.I encountered a security exception with Netscape in Linux when attempting applet-servlet stuff but that's prpbably because I haven't got the plugin for that yet...in fact I don't know if a plugin is available for sure...let me know if you do. As a matter of fact I plan on using the HTMLConverter this weekend to find out if it'll download a plugin.
The applet-servlet thing runs fine in IE and Netscape on my Windows box as long as the plugins are there and I use the appropriate plugin tags in the HTML
Post what you find out,
Brad -
Applet-Servlet or RMI - which is better
We are in the process of developing a swing-applet based system that requires regular interaction with multiple databases residing on more than one database server.
The options available before us, as we evaluate are:
a. Use "signed" applets ( as this is going to be essentially an intra-net application) and use JDBC connection to connect to more than one database ( which reside on servers other than the web server).
b. Use applet - servlet communication - basically, the servlet would establish connection to the databases, directly or through EJB, retrieve necessary database information and pass on the objects to the applet - the front end GUI would be controlled by the applet.
c. Use RMI
We would like to have your perspective of the three options, with your experience in this line.
The questions that come to us are:
a. If the system is essentially an intra-net application, is it okay to design with "signed" applet mechanism - how far is this method common in the market and acceptable to the clients? Is it true that the signed applet would be able to establish connection to various "identified servers" that are allowed permissions in the security file?
b. Between applet-servlet and RMI, which is a better method? What should be the factors that need to be considered? Is RMI being widely used or should we be thinking in terms of EJB, eventhough the current project is purely a Java based solution.
Your input is highly appreciated - thanking in advance for any suggestions and inputs that you may provide.
Thanks
DixieDixie,
1) IMHO signed applets are not widely used, but you can use
ordinary applets, which are accessing other resources through
redirector servlet on server side - I mean ordinary applets
are prohibited to establish connect to other than it's own server.
So you will be forced to have special servlet on your server,
which have access to other resources on other servers - this is a
way how to avoid applets limitation.
2) RMI is a heavy solution, because all parameters/objects should
be serialized over net and if network connection is unreliable
working with system will be just a nighmare.
3) If you think that your network connection is unreliable, you can use HTTP protocol between client and server instead of RMI. In this case
you will have following benefits:
i) You can still use all of powerness of thick client
ii) Network unreliability will be defeated
iii) Sometime if you would like to port your application to a thin
client it will be done much more easier than in case of RMI
4) If you would like to use thin client your only problem will
be poorness of UI - if you can go with it - go ahead! Otherwise
use thick client with RMI or HTTP depending on quality of network.
Paul -
How to show progress - Applet - Servlet
Hi,
I am new to applet-servlet communication. I have to show the progress at the applet front-end using a JProgressBar for a task being done at the servlet end. I request the gurus on the forum to post any example code for the above situation.Hi,
U will have to use the SwingWorker to popup the JProgressBar, but in here i dont think u will be getting any input from servlet giving the job completed, if u are using jdk1.4.1 u can use
setIndeterminate(true);
I am attaching 2 methods below which i use to display the JProgressBar
Method long task is where i actually call the servlet and in method buildData i create the URLConnection etc
//appletData must implement Serializable
public void buildData(Object appletData)throws Exception
//define servlet name here
ObjectInputStream inputFromServlet = null;
URL studentDBservlet = new URL("MyServlet");
URLConnection servletConnection = studentDBservlet.openConnection();
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
servletConnection.setUseCaches(false);
servletConnection.setRequestProperty("Content-Type", "application/octet-stream");
ObjectOutputStream outputToServlet =
new ObjectOutputStream(servletConnection.getOutputStream());
// serialize the object
if (!SwingUtilities.isEventDispatchThread())
outputToServlet.writeObject(input);
outputToServlet.flush();
outputToServlet.close();
inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
else
inputFromServlet = longTask(servletConnection, outputToServlet, appletData);
private ObjectInputStream longTask(final URLConnection servletConnection,
final ObjectOutputStream outputToServlet,
final Object appletData)
final JDialog dialog = new JDialog(PlanApplet.appletFrame, "Please Wait", true);
isProcess = true;
MapsPanel panel = new MapsPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
//MapsLabel label = new MapsLabel("Work in process....");
//label.setFont(Constant.bigFont);
//label.setPreferredSize(new Dimension(230, 40));
JProgressBar progressBar = new JProgressBar();
progressBar.setIndeterminate(true);
progressBar.setPreferredSize(new Dimension(140, 30));
// final JugglerLabel jugLabel = new JugglerLabel();
// jugLabel.startAnimation();
// panel.setPreferredSize(new Dimension(175, 175));
MapsPanel progressPanel = new MapsPanel(new FlowLayout(FlowLayout.CENTER, 5, 5));
progressPanel.setPreferredSize(new Dimension(140, 80));
progressPanel.add(progressBar);
// progressPanel.add(jugLabel);
// panel.add(Box.createVerticalStrut(5));
//panel.add(label);
panel.add(Box.createVerticalStrut(15));
panel.add(progressPanel);
panel.add(Box.createVerticalStrut(15));
dialog.setSize(150, 115);
dialog.setResizable(false);
// dialog.getContentPane().add(jugLabel);
dialog.getContentPane().add(panel);
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
dialog.setLocation(ScreenSize.getDialogLocation(dialog));
// final javax.swing.Timer popupTimer = new javax.swing.Timer(2000, new TimerListener(dialog));
final SwingWorker worker = new SwingWorker()
public Object construct()
try
PlanApplet.applet.setCursor(new Cursor(Cursor.WAIT_CURSOR));
outputToServlet.writeObject(appletData);
outputToServlet.flush();
outputToServlet.close();
return new ObjectInputStream(servletConnection.getInputStream());
catch (Exception exc)
return null;
public void finished()
// jugLabel.stopAnimation();
dialog.dispose();
Toolkit.getDefaultToolkit().beep();
isProcess = false;
LogWriter.out("the long process is finished", LogWriter.BASIC);
worker.start();
// popupTimer.start();
//System.out.println("Process complete");
dialog.show();
// while(isProcess)
return (ObjectInputStream) worker.getValue();
Maybe you are looking for
-
Credit card Orders are getting blocked with credit check
Hi All In our system, If customer's credit exposure is greater then 100 % then all the credit card orders are getting blocked with credit check even though it has valid authorization. Is this sap standard behaviour?....is there any setting that will
-
A parameter of CM repository manager
In CM repository manager,there is a parameter called "Compress content greater than".I don't know wether it will compress content when the all documents of it greater than the parameter or it will compress the document when the uploaded document grea
-
OK to have separate virus progams in Mac and in Windows?
I am advised to have virus protection in the Windows XP program I have just installed in Parallels. I already have McAfee Virus Scan on my Mac. Is it okay to load in the McAfee Virus Scan software for Windows into Windows? I saw a warning about havin
-
What type of audio files does itunes work with?
i mean is it just mp3? can i use wav snd dwd sng what can i use?
-
Hello. I have a site with a template and a menu built from graphic buttons. Here is a button from my template : <p><a href="../mypage1.html" class="@@(attr_1)@@"><img src="../web_images/mybutton1.gif" width="100" height="35" class="nostyle" longdesc=