URGENT - Applet
Hi there,
I have a problem that I urgently need fixed. I have an applet which runs fine on my local machine i.e. using localhost. But when I connect to the network and try to run it off another machine the screen is grey. The bottom of the screen says �Applet Appletname started�. I am not getting any errors. The following it the HTML file used:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>
Route Planner
</TITLE>
</HEAD>
<body bgcolor="silver">
<BR>
<!--"CONVERTED_APPLET"-->
<!-- CONVERTER VERSION 1.3 -->
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH = 1020 HEIGHT = 1350 NAME = "Route Planner" ALIGN = middle codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">
<PARAM NAME = CODE VALUE = "Router.class" >
<PARAM NAME = CODEBASE VALUE = "." >
<PARAM NAME = ARCHIVE VALUE = "Router.jar" >
<PARAM NAME = NAME VALUE = "Route Planner" >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
<PARAM NAME="scriptable" VALUE="false">
<COMMENT>
<EMBED type="application/x-java-applet;version=1.3" CODE = "Router.class" CODEBASE = "." ARCHIVE = "Router.jar" NAME = "Route Planner" WIDTH = 1020 HEIGHT = 1350 ALIGN = middle scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html">
<NOEMBED>
</COMMENT>
</NOEMBED></EMBED>
</OBJECT>
<!--
<APPLET CODE = "Router.class" CODEBASE = "." ARCHIVE = "Router.jar" WIDTH = 1020HEIGHT = 1350 NAME = "Route Planner" ALIGN = middle>
</APPLET>
-->
<!--"END_CONVERTED_APPLET"-->
</BODY>
</HTML>
<!--"END_CONVERTED_APPLET"-->
</BODY>
</HTML>
I used the HTML Converter to generate this because I�m using a JApplet(It�s a swing application). I have a folder called Router which contains: Router_Router.html(above) and Router.jar(contains all the class files). I also have the class files all copied into this folder.The applet is called Router.java.
Hope someone can help!
Thanks
Jacintha
I'm also having another problem which might actually be my whole problem - in the applet I want to display an image - I have the following code:
public Image getImage(){
Image img = getToolkit().getImage("C:/road.jpg");
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(img,0);
try{
tracker.waitForID(0);
catch (InterruptedException e){}
return img;
But of course I cant do this ("C:...") when I want to run over the network - so when I use the ip address of my machine when running it in a browser on my local machine - the image does not appear. Where should I put this image - beside the HTML files and the jar?? in the jar? Or will it be relative to where the .java files is? These are seperate to the folder containing the HTML file.
Similar Messages
-
Extremely urgent !!! I like someone to takeover this project or guide me through it - I can compensate if you take it over. I have the source codes but I can't seem to compile them - what IDE can I use to get started.
View this java applet that lets users create and save an image.
I would like users to be able to save a graphic from the current java applet. Then I would like them to be able to put this graphic in one of a few templates and charge them for printing permissions.
So the program must not let the user use "view source" to get the picture or to right click and "save as."(Not very important)
What I am looking for is a new applet that will combine the images with stationary templates and to be able to charge for printing. The background images in the applet also need to be exchanged with new ones.
__________________Here are my Netbeans run / debug messages for my clients source - it says build successful but I never see a running applet or anything. Any advise please - ??? I've changed the sources file path around etc but no luck. I might have to quit this soon.
init:
deps-jar:
compile:
java.lang.NullPointerException
at com.dolls.ImageStore.loadImage(ImageStore.java:81)
at com.dolls.Image.load(Image.java:52)
at com.dolls.Image.<init>(Image.java:39)
at com.dolls.DollImage.<init>(DollImage.java:20)
at com.dolls.editor.Editor.<clinit>(Editor.java:44)
Error when loading image:style1/bodies/body-medium.gif
java.lang.ExceptionInInitializerError
Caused by: java.lang.NullPointerException
at com.dolls.Image.load(Image.java:55)
at com.dolls.Image.<init>(Image.java:39)
at com.dolls.DollImage.<init>(DollImage.java:20)
at com.dolls.editor.Editor.<clinit>(Editor.java:44)
Exception in thread "main" ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183): [../../../src/share/back/util.c:820]
Java Result: 1
debug:
BUILD SUCCESSFUL (total time: 2 seconds) -
Hi All,
I have a following problem. I have included a JTable inside a JScrollPabe in an applet.
However when the web page loads. There is nothing shown. When I tried 'refreshing' the page several times in quick succession , occasionally the contents is shown. What coule be the problem?
Another issue is when I switch to another application, the contents disappear again. How can i fix the contents without it disapperaing when the web page is minimised or has lost focus?
Below is the code for my applet.
import javax.swing.JApplet;
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
import java.io.*;
import java.util.*;
import java.net.*;
import com.sns.legal.lit.applet.*;
public class Simple extends JApplet{
//private MultiLineTable table = null;
//private Vector vecResult = null;
public Simple() {
public void init() {
public void start() {
Object[][] data = new Object[][] {{"first row", "\"I was drunk last night, crawled home across the lawn. By accident I put the car key in the door lock. The house started up. So I figured what the hell, and drove it around the block a few times. I thought I should go park it in the middle of the freeway and yell at everyone to get off my driveway.\"\n -- Steven Wright"},
{"second row", "The most advantageous, pre-eminent thing thou canst do is not to exhibit nor display thyself within the limits of our galaxy, but rather depart instantaneously whence thou even now standest and flee to yet another rotten planet in the universe, if thou canst have the good fortune to find one.\n -- Carlyle"}};
Object[] columns = new Object[] {"first column", "fortune cookie"};
JTable table2 = new JTable(data, columns);
System.out.println("Start.......................");
JScrollPane scrollPane = new JScrollPane(table)
this.getContentPane().add(scrollPane, BorderLayout.CENTER);
this.setVisible(true);
System.out.println("End.......................");
public void stop() {
public void destroy() {
public void paint(Graphics g){
} Thank alot!You haven't set the Layout of the getContentPane() to new BorderLayout()
You make the assumption that thats the default layout manager.
Try adding that first.
You may have to add some pack() or doLayout() calls at the end of your start() routine if it still doesn't work.
regards,
Owen -
how can rotate a picture clockwise or counter-clockwise using applets-URGENT
/* <applet code="RotatingAnImage" width="400" height="400"></applet>
* use: >appletviewer RotatingAnImage.java
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.*;
import javax.imageio.ImageIO;
import javax.swing.*;
public class RotatingAnImage extends JApplet
ImageManager manager;
RotatingImagePanel imagePanel;
public void init()
manager = new ImageManager();
imagePanel = new RotatingImagePanel(manager.getImage());
getContentPane().setLayout(new BorderLayout());
getContentPane().add(getUIPanel(), "North");
getContentPane().add(new JScrollPane(imagePanel));
private JPanel getUIPanel()
final JButton
ccw = new JButton("ccw"),
cw = new JButton("cw"),
save = new JButton("save");
ActionListener l = new ActionListener()
public void actionPerformed(ActionEvent e)
JButton button = (JButton)e.getSource();
if(button == ccw)
imagePanel.rotate(-1);
if(button == cw)
imagePanel.rotate(1);
if(button == save)
manager.save(imagePanel, imagePanel.theta);
ccw.addActionListener(l);
cw.addActionListener(l);
save.addActionListener(l);
JPanel panel = new JPanel();
panel.add(ccw);
panel.add(cw);
panel.add(save);
return panel;
public static void main(String[] args)
JApplet applet = new RotatingAnImage();
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(applet);
f.setSize(400,400);
f.setLocation(200,200);
applet.init();
f.setVisible(true);
class RotatingImagePanel extends JPanel
BufferedImage image;
double theta, thetaInc;
public RotatingImagePanel(BufferedImage image)
this.image = image;
theta = 0;
thetaInc = Math.PI/6; // 30 degrees
protected void paintComponent(Graphics g)
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
int w = getWidth();
int h = getHeight();
int imageWidth = image.getWidth();
int imageHeight = image.getHeight();
int x = (w - imageWidth)/2;
int y = (h - imageHeight)/2;
AffineTransform at = AffineTransform.getTranslateInstance(x, y);
at.rotate(theta, w/2 - x, h/2 - y);
g2.drawRenderedImage(image, at);
public Dimension getPreferredSize()
double cos = Math.abs(Math.cos(theta));
double sin = Math.abs(Math.sin(theta));
int w = (int)(image.getWidth() * cos + image.getHeight() * sin);
int h = (int)(image.getWidth() * sin + image.getHeight() * cos);
return new Dimension(w, h);
public void rotate(int direction)
theta += thetaInc * direction;
revalidate();
repaint();
class ImageManager
BufferedImage image;
public ImageManager()
loadImage();
private void loadImage()
String fileName = "images/redfox.jpg";
try
URL url = getClass().getResource(fileName);
image = ImageIO.read(url);
catch(MalformedURLException mue)
System.err.println("url: " + mue.getMessage());
catch(IOException ioe)
System.err.println("read: " + ioe.getMessage());
public void save(Component c, double theta)
double cos = Math.abs(Math.cos(theta));
double sin = Math.abs(Math.sin(theta));
int w = (int)(image.getWidth() * cos + image.getHeight() * sin);
int h = (int)(image.getWidth() * sin + image.getHeight() * cos);
BufferedImage bi = new BufferedImage(w, h, image.getType());
Graphics2D g2 = bi.createGraphics();
int x = (c.getWidth() - w)/2;
int y = (c.getHeight() - h)/2;
g2.translate(-x, -y);
c.paint(g2);
g2.dispose();
try
ImageIO.write(bi, "png", new File("rotatingAnImage.png"));
catch(IOException ioe)
System.err.println("write: " + ioe.getMessage());
public BufferedImage getImage()
return image;
} -
Applet notinited .. it runs in eclipse, but not in web browser --urgent
hi,
firstly i'm sorry for the "urgent" remark in the title, but I actually really need some help to this problem, since I have to pass up this assignment in about 2 more hours.
on to the question,this is my full code:
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
public class reza extends JApplet{
public static void main(String[] args){
JFrame myWindow = new JFrame("Sample reza");
myWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
reza testReza = new reza();
myWindow.setContentPane(testReza);//add to the window
myWindow.pack();
myWindow.setVisible(true);
double sum; //sum of values entered by user
private ImageIcon board;
private JPanel topPanel,boardPanel;
private JLabel l1,l2,l3,l4,l5,l6,lTotal,lAndryusha,lBorya,lVolodya,lGiveUp,lGiveUp2,boardLabel,lRules;
private JTextField a[],aTotal, b[], bTotal, c[], cTotal;
private JButton clear,checkAnswer,solve;
private Container container;
String A1,A2,A3,A4,A5,A6,ATOTAL,B1,B2,B3,B4,B5,B6,BTOTAL,C1,C2,C3,C4,C5,C6,CTOTAL;
public reza(){
container = getContentPane();
container.setLayout(new BorderLayout());
topPanel = new JPanel(new GridLayout(6,8,5,5));
boardPanel = new JPanel(new GridLayout(1,2,5,5));
board = new ImageIcon("board.jpg");
boardLabel = new JLabel(board);
topPanel.setBackground(Color.WHITE);
boardPanel.setBackground(Color.white);
//utk handle button clear ngan solve
ButtonHandler handler = new ButtonHandler();
lGiveUp = new JLabel(" Give up?");
lGiveUp2 = new JLabel("Press this >>>");
lRules = new JLabel("Rules: User may only use the number shown in the dart board");
l1 = new JLabel(" 1");
l2 = new JLabel(" 2");
l3 = new JLabel(" 3");
l4 = new JLabel(" 4");
l5 = new JLabel(" 5");
l6 = new JLabel(" 6");
lTotal = new JLabel(" Total");
lAndryusha = new JLabel("Andryusha");
lBorya = new JLabel("Borya");
lVolodya = new JLabel("Volodya");
a = new JTextField[7];
b = new JTextField[7];
c = new JTextField[7];
aTotal = new JTextField();
bTotal = new JTextField();
cTotal = new JTextField();
clear = new JButton("CLEAR");
solve = new JButton("SOLVE");
checkAnswer = new JButton("ANSWER");
topPanel.add(new JLabel(" "));
topPanel.add(l1);
topPanel.add(l2);
topPanel.add(l3);
topPanel.add(l4);
topPanel.add(l5);
topPanel.add(l6);
topPanel.add(lTotal);
topPanel.add(lAndryusha);
int i=1;
for (i=1;i<=6;i++){
a[i] = new JTextField();
a.getDocument().addDocumentListener(new textFieldListenerA());
topPanel.add(a[i]);
topPanel.add(aTotal);
topPanel.add(lBorya);
for (i=1;i<=6;i++){
b[i] = new JTextField();
b[i].getDocument().addDocumentListener(new textFieldListenerB());
topPanel.add(b[i]);
topPanel.add(bTotal);
topPanel.add(lVolodya);
for (i=1;i<=6;i++){
c[i] = new JTextField();
c[i].getDocument().addDocumentListener(new textFieldListenerC());
topPanel.add(c[i]);
topPanel.add(cTotal);
clear.addActionListener(handler);
solve.addActionListener(handler);
checkAnswer.addActionListener(handler);
topPanel.add(new JLabel(" "));
topPanel.add(new JLabel(" "));
topPanel.add(new JLabel(" "));
topPanel.add(new JLabel(" "));
topPanel.add(new JLabel(" "));
topPanel.add(new JLabel(" "));
topPanel.add(clear);
topPanel.add(solve);
topPanel.add(new JLabel(" "));
topPanel.add(lGiveUp);
topPanel.add(lGiveUp2);
topPanel.add(checkAnswer);
topPanel.add(new JLabel(" "));
topPanel.add(new JLabel(" "));
topPanel.add(new JLabel(" "));
topPanel.add(new JLabel(" "));
boardPanel.add(boardLabel,BorderLayout.WEST);
boardPanel.add(lRules,BorderLayout.EAST);
container.add(boardPanel,BorderLayout.NORTH);
container.add(topPanel,BorderLayout.CENTER);
setSize(750,700);
setVisible(true);
class textFieldListenerA implements DocumentListener{
public void insertUpdate(DocumentEvent e){
int i,count=0;
for (i=1;i<=6;i++){
try{
count = count + Integer.parseInt(a[i].getText());
}catch(Exception e1){
aTotal.setText("" + count);
public void changedUpdate(DocumentEvent e){
public void removeUpdate(DocumentEvent e){
class textFieldListenerB implements DocumentListener{
public void insertUpdate(DocumentEvent e){
int i,count=0;
for (i=1;i<=6;i++){
try{
count = count + Integer.parseInt(b[i].getText());
}catch(Exception e1){
bTotal.setText("" + count);
public void changedUpdate(DocumentEvent e){
public void removeUpdate(DocumentEvent e){
class textFieldListenerC implements DocumentListener{
public void insertUpdate(DocumentEvent e){
int i,count=0;
for (i=1;i<=6;i++){
try{
count = count + Integer.parseInt(c[i].getText());
}catch(Exception e1){
cTotal.setText("" + count);
public void changedUpdate(DocumentEvent e){
int i,count=0;
for (i=1;i<=6;i++){
try{
count = count + Integer.parseInt(c[i].getText());
}catch(Exception e1){
cTotal.setText("" + count);
public void removeUpdate(DocumentEvent e){
int i,count=0;
for (i=1;i<=6;i++){
try{
count = count + Integer.parseInt(c[i].getText());
}catch(Exception e1){
cTotal.setText("" + count);
private class ButtonHandler implements ActionListener{
//handle button event
public void actionPerformed(ActionEvent event){
//clear all the text fields
if (event.getActionCommand().equals("CLEAR")){
int i=0;
for (i=1;i<=6;i++){
a[i].setText("");
aTotal.setText("");
for (i=1;i<=6;i++){
b[i].setText("");
bTotal.setText("");
for (i=1;i<=6;i++){
c[i].setText("");
cTotal.setText("");
else if (event.getActionCommand().equals("SOLVE")){
int aCount[],bCount[],cCount[],i,aTotal=0,bTotal=0,cTotal=0;
aCount = new int[7];
bCount = new int[7];
cCount = new int[7];
//make sure all fields have been filled in
if (a[1].getText().equals("") || a[2].getText().equals("") || a[3].getText().equals("")|| a[4].getText().equals("")|| a[5].getText().equals("")|| a[6].getText().equals("")|| b[1].getText().equals("")|| b[2].getText().equals("")|| b[3].getText().equals("")|| b[4].getText().equals("")|| b[5].getText().equals("")|| b[6].getText().equals("")|| c[1].getText().equals("")|| c[2].getText().equals("")|| c[3].getText().equals("")|| c[4].getText().equals("")|| c[5].getText().equals("")|| c[6].getText().equals("")){
JOptionPane.showMessageDialog(null,"Please fill in ALL the scores!!");
//if yes, then only proceed
else{
//for andryusha
for (i=1;i<=6;i++){
try{
aCount[i] = Integer.parseInt(a[i].getText());
aTotal = aTotal + aCount[i];
}catch(Exception e1){
//check andryusha's 1st and 2nd shots. They must be equal to 22 when added
if (aCount[1] + aCount[2] != 22){
JOptionPane.showMessageDialog(null,"Andryusha's 1st + 2nd shots must be equal to 22!!");
if (aTotal==71){
JOptionPane.showMessageDialog(null,"Andryusha's scores is right! Well done!!");
}else if (aTotal !=71){
JOptionPane.showMessageDialog(null,"You got it wrong for Andryusha's scores. Please try again.");
//for Borya
for (i=1;i<=6;i++){
try{
bCount[i] = Integer.parseInt(b[i].getText());
bTotal = bTotal + bCount[i];
}catch(Exception e1){
if (bTotal==71){
JOptionPane.showMessageDialog(null,"Borya's scores is right! Well done!!");
}else if (bTotal !=71){
JOptionPane.showMessageDialog(null,"You got it wrong for Borya's scores. Please try again.");
//for Volodya
for (i=1;i<=6;i++){
try{
cCount[i] = Integer.parseInt(c[i].getText());
cTotal = cTotal + cCount[i];
}catch(Exception e1){
if (cCount[1] != 3){
JOptionPane.showMessageDialog(null,"Volodya's first score is wrong!!");
if (cTotal==71){
if (cCount[2] == 50 || cCount[3] == 50 || cCount[4] == 50 || cCount[5]==50 || cCount[6]==50){
JOptionPane.showMessageDialog(null,"Volodya's score is right! Well done!!");
}else if (cCount[2] != 50 && cCount[3] != 50 && cCount[4] != 50 && cCount[5]!=50 && cCount[6]!=50){
JOptionPane.showMessageDialog(null,"Volodya hits the bull's eye once!!");
}else if (cTotal!=71){
JOptionPane.showMessageDialog(null,"Volodya's score is wrong!!");
}else if(event.getActionCommand().equals("ANSWER")){
a[1].setText("20");
a[2].setText("2");
a[3].setText("25");
a[4].setText("3");
a[5].setText("20");
a[6].setText("1");
aTotal.setText("71");
b[1].setText("25");
b[2].setText("20");
b[3].setText("20");
b[4].setText("3");
b[5].setText("2");
b[6].setText("1");
bTotal.setText("71");
c[1].setText("3");
c[2].setText("50");
c[3].setText("10");
c[4].setText("5");
c[5].setText("2");
c[6].setText("1");
cTotal.setText("71");
}//end private class ButtonHandler
I run the program using Eclipse; run as> Java applet
and in runs perfectly well. I then tried running it using internet explorer and firefox, but only a gray box appeared and the browser says "applet notinited" and "Loading Java Applet Failed.."
what did i do wrong? any help is really appreciated.. thanksthank God i already found the cause of the problem..
it's because the application has an ImageIcon which links to a local jpeg file, so perhaps security restriction on the browser doesn't allow my applet to access local file, that's why it fails to load.
either using signed applet (not tested) or removing the picture solved my problem.
thanks anyway :) -
Applet does not work with a proxy server.URgent
Hi,
I have an asp page being hosted from a IIS server.
The asp page has an applet which gets data from a server side component which is hosted as a service on the server side.For connection to the server I am using URLConnection object and trying to connect over a TCP connection.
The problem occurs when I use an proxy in the middle.
I have changed the browser settings to include the proxy.
The following is the error I recieve:
Full :http://172.25.11.63:4590/
<-------------------------------->
OPening input stream
in Run ::::
ERROR: Created data socket but can't open stream on
it.172.25.11.63:4590//
172.25.11.63:4590//
java.io.FileNotFoundException: 172.25.11.63:4590//
at com/ms/net/wininet/http/HttpInputStream.connect
at com/ms/net/wininet/http/HttpInputStream.<init>
at com/ms/net/wininet/http/HttpURLConnection.createInputStream
at com/ms/net/wininet/WininetURLConnection.getInputStream
at TalkClientApplet.rendezvous
at TalkClientApplet.actionPerformed1
at TalkClientApplet.start
at com/ms/applet/AppletPanel.securedCall0
at com/ms/applet/AppletPanel.securedCall
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.run
at java/lang/Thread.run
...Disconnecting.
Following is my code.
url = new URL("http://" + host +":"+i);
urlconnection = url.openConnection();
urlconnection.setDoOutput(true);
urlconnection.setDoInput(true);
System.out.println("Successfully opened the URL connection at " + "http://" + host + ":" + i );
System.out.println ("Protocol: " + url.getProtocol());
System.out.println ("Host :" + url.getHost());
System.out.println ("Port :" + url.getPort());
System.out.println ("File :" + url.getFile() );
System.out.println ("Full :" + url.toExternalForm());
System.out.println ("<-------------------------------->");
os = new BufferedWriter(new OutputStreamWriter(urlconnection.getOutputStream()));
System.out.println("OPening input stream ");
// is = new DataInputStream(urlconnection.getInputStream());
System.out.println(urlconnection.getInputStream());
is = new DataInputStream(urlconnection.getInputStream());
The exact place where I get the error is whn i call URLConnection.openInputStream().
Usually this error comes with a malformed URL.But the same code words without a proxy.Also I am not making any changes to my code in both scenarios that is with or without proxy.
Please help.This is urgent and a showstopperThanks for your nice solution, but unfortunatelly it does not work with lines longer than 100 chars with Netscape. It works fine with IE and appletviewer too.
Example:
I use this code:
try {
URL url = new URL(protocol,hostName,portNumber,URLstring);
InputStream in = url.openStream();
BufferedInputStream bis = new BufferedInputStream(in);
StringBuffer input = new StringBuffer(60);
int c;
while ((c = bis.read()) != -1){
System.out.print((char)c);
input.append((char)c);
bis.close();
dataFromServer = input.toString();
catch(Exception ex) {
ex.printStackTrace();
}I use input file test.html with exactly 100 chars ('a')
Netscape Java Console:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadataFromServer : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaI use input file test.html with exactly 101 chars ('a')
Netscape Java Console:
?JL?yyxk?cedataFromServer : ? -
DOM parsing In Applet (URgent)
Is it possible to implement DOM parsing in Applet?
I am getting classnotfoundException .
I am giving the code below. pl read the code.
Applet.(parserapplet.java)
=========================
import java.io.*;
import java.awt.*;
import java.net.*;
import java.util.*;
import java.applet.*;
import com.security.*;
// for DOM parsing ....
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.w3c.dom.Document;
import org.w3c.dom.DOMException;
public class parserapplet extends Applet
public void init()
public void start()
try
if (Class.forName("com.ms.security.PolicyEngine") != null)
{ // required for IE
PolicyEngine.assertPermission( PermissionID.SYSTEM );
catch (Throwable cnfe)
System.out.println("Policy Engine Exception: " + cnfe);
try
String str = "<?xml
version=\"1.0\"?><html><body></body></html>";
ByteArrayInputStream bis = new
ByteArrayInputStream(str.getBytes());
System.out.println("After creating input stream");
BufferedInputStream bufIn = new BufferedInputStream(new
DataInputStream(bis));
parseXMLMessage (bufIn);
catch(Exception e){}
// Actual DOM parsing goes here.....
public void parseXMLMessage(InputStream xmlMessage)
Document document = null;
DocumentBuilder documentBuilder = null;
DocumentBuilderFactory documentBuilderFactory = null;
try
documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilder = documentBuilderFactory.newDocumentBuilder();
document = documentBuilder.parse(xmlMessage);
System.out.println("Document node: " + document);
catch(FactoryConfigurationError fce)
System.out.println("Exception Factory configuration error " + fce);
catch(ParserConfigurationException pce)
System.out.println("Exception Parser configuration Exception " pce);
catch(SAXException saxe)
System.out.println("Exception SAX error " + saxe);
catch(Exception e)
System.out.println("Exception " + e);
Html code:
=========
<html>
<body>
<APPLET code="parserapplet.class" archive = "xalan.jar" width=0
height=0
MAYSCRIPT>
<param name=cabbase value=MyApplet.cab>
</APPLET>
</body>
</html>
I have signed the Applet using signcode utility and i have put the
parserapplet.class in the MyApplet cab file and signed it. On invoking
the html file, it request for permission, and after clicking yes, the
applet loads.Fine.
No problem upto this stage.
But after loading of the applet the following exception is thrown in
Javaconsole.
Exception:
=========
com.ms.security.SecurityExceptionEx[Host]: cannot access file
C:\WINNT\Java\lib\jaxp.properties
at com/ms/security/permissions/FileIOPermission.check
at com/ms/security/PolicyEngine.deepCheck
at com/ms/security/PolicyEngine.checkPermission
at com/ms/security/StandardSecurityManager.chk
at com/ms/security/StandardSecurityManager.checkRead
at java/io/File.exists
at javax/xml/parsers/DocumentBuilderFactory.findFactory
at javax/xml/parsers/DocumentBuilderFactory.newInstance
at parserapplet.parseXMLMessage
at parserapplet.init
at com/ms/applet/AppletPanel.securedCall0
at com/ms/applet/AppletPanel.securedCall
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.run
at java/lang/Thread.run
javax.xml.parsers.FactoryConfigurationError:
java.lang.ClassNotFoundException:
org/apache/crimson/jaxp/DocumentBuilderFactoryImpl
at javax/xml/parsers/DocumentBuilderFactory.newInstance
at parserapplet.parseXMLMessage
at parserapplet.init
at com/ms/applet/AppletPanel.securedCall0
at com/ms/applet/AppletPanel.securedCall
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.run
at java/lang/Thread.run
I dont know which .jar file to archive (i tried xalan,crimson, jaxp
but which of no use). I was surprised why the security Exception is
thrown , when parsing.
I have not accessed the System files!( but it searches for
jaxp.properties file!). I think the jar file is not downloaded. How to
verify that it is downloaded in applet?
The above code is only for sample.
If anybody who knows how to correct it please mail me at:
"[email protected]" with corrected code. I want this very
urgently.
Help meeeeeeeeeeeeeeeeeeee!!!!!
Prasanna.Have you found the answer to this problem? I am having a similar problem when running the parser in an ActiveX Bean.
THanks -
ClassNotFoundException in applet-urgent
Hai
I am having an applet "tstapplet" whose class file is stored in a jar file and the applet is inside a package named test.
I wrote the following applet tag
<applet code="tstapplet.class" archive="../deploy/showj.jar">
</applet>
I am getting ClassNotFoundException ; tstapplet.class
What should I do Is the applet code wrong
Plz help urgent
tintuthilak<applet code="test.tstapplet" archive="../deploy/showj.jar">
</applet>
Try to open it with Firefox or Mozilla (you can be sure MSJVM does not try to open
the applet).
When it works convert the html page with [jdk.home]\bin\htmlconverter.exe -
Applets loading issue in Weblogic portal 10.3 - urgent
Hi,
We are upgrading WLP 8.1 to WLP 10.3, I am facing an issue on loading an applet on the client browser getting class not found exception.
The applet tag in WLP 8.1
=================
<applet name="ThisApplet" code="PrintFormApplet.class"
codebase="/bea_wls_internal/classes/projectApp@projectportal/" MAYSCRIPT height=28 width=90 >
<PARAM NAME=lastformNum VALUE="<%=lastformNum%>"/>
</applet>
works fine in WL 8.1 with any problem.
WLP 10.3 and plug-in using JRE 1.6
=======================
In Weblogic 10.3 I am getting an error class not found exception.
Is there any change to be done on the applet codebase tage ?
codebase="/bea_wls_internal/classes/"
What is the equivalent codebase to be used in WL 10.3?
This is an urgent issue to be solved. pls help on this issue asap.
Thanks,
Santha.Solved my self:
Don't use the .class in the code tag
problem
=====
<applet name="ThisApplet" code="PrintFormApplet.class"
codebase="/bea_wls_internal/classes/projectApp@projectportal/" MAYSCRIPT height=28 width=90 >
<PARAM NAME=lastformNum VALUE="<%=lastformNum%>"/>
</applet>
solution:
======
<applet name="ThisApplet" code="PrintFormApplet"
codebase="/bea_wls_internal/classes/projectApp@projectportal/" MAYSCRIPT height=28 width=90 >
<PARAM NAME=lastformNum VALUE="<%=lastformNum%>"/>
</applet> -
Please Urgent sound applet in jsp problem
Hi please any body hekp me urgently.
I have a problem while playing a sound applet in the jsp file the error is class not found.
My applet class file is in the com.mypack.common
its code is
public class PlayErrorSoundApplet extends Applet
public PlayErrorSoundApplet()
public void init()
public void playSound()
String soundObj = getParameter("soundObj");
AudioClip sound = getAudioClip(getDocumentBase(), "success.wav");
sound.play();
in the jsp i have written the code like this
<applet codebase="com.mypack.common" code="PlayErrorSoundApplet.class" name="soundApplet" width="0" height="0">
<param name="soundObj" value="error.wav">
</applet>
In the applet console i got class not found error.
please help me .....advanced thanks......actually, codbase is a directory. so
<applet codebase="com/mypack/common" code="PlayErrorSoundApplet.class" name="soundApplet" width="0" height="0">
<param name="soundObj" value="error.wav">
</applet>this means you have something like
pacakge com.mypack.common
public class PlayErrorSoundApplet {
Make sure to put the html file in the root directory of the package structure
/myhtmlfile.html
/com
/mypack
/common
PlayErrorSoundApplet.class -
Problem on loading applet netscape4.73 in macos9 very urgent pls help me
Hello,
Problems on loading applet in Netscape4.73(jre1.1.5) AppleMac OS-9.
when i try to load applet of size ~ 200kb in Netscape 4.73 AppleMac os9, then browser abruptly closing with the AppleMac os error message :- the Applicarion " Netscape Communicator " has unexpectedly quit because an error of type 2 occured. And then asking for system restart.
Since i am new to the AppleMac environment i cant adjust the settings please help me to overcome the problem. Its Very urgent and i am in great hurry pls.
thanks in advance.
Rao. V.N.Hi Rao,
I'm not a mac-os specialist (even I had some business with mac !!), and it is very difficult speaking in blind, but I have severals questions that may help you.
- Did you try you applet in other AppleMac plateform ?
- Does your applet work fine in other browser/plateform ?
- Does a small applet work fine on this plateform with this browser ?
- Does you applet contains instructions like System.exit, System.* or try to access (read or write) to local files ?
Otherelse it is possible you have problem with your jre config, try to configure your plugin with command like : -Xmx64m -Xms16m
(These commands tell the plugin to use at least 16 Mo memory and 64 Mo for the maximum see : http://java.sun.com/docs/hotspot/gc/)
Hope that will help you -
Urgent : store and retrieve image to oracle database thru applet
hi all
i want the code sample for storing the image to oracle database
development enviornment:
server : oracle 9i , apache web server
client : ie6 browser
i am connecting to oracle database thru applet using oracle jdbc thin driver
can anyone give me details about storing image to db
1) what datatype should be used in table for image?
2) my image files are on client machine... can i directly read those files from browser or first i have to copy those files to server?
3) .gif files will do or what should be the fileformat?
4) java code to store it to database (i am using jdk1.3)
5) how to retrieve it back from database and display it in awt panel ?
its very urgent ...
i am doing some r&d and trying to do using blob....
but it will take some time ...
i will really be thankful if someone sends detail code....
thankx in advance ....Hi,
The code below might answer few of your questions.
There is a restrcition on size of image, it must be less than 4KB.
//Code to insert image in database
//mytable is the table name that contains two fields in databse:name,image of type varchar and blob
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con =null ;
Statement stmt =null ;
con =DriverManager.getConnection ("jdbc:oracle:thin:@<hostname>:1521:orclsid", "system","manager");
PreparedStatement preparedStatement = con.prepareStatement("insert into mytable (name,image) values (?,?)");
preparedStatement.setString(1,"Amol");
InputStream inputStream = new BufferedInputStream(new FileInputStream("C:\\WINNT\\Temp\\netscape\\images\\menubg.jpg"));
preparedStatement.setBinaryStream(2, inputStream, inputStream.available());
preparedStatement.executeUpdate();
preparedStatement.close();
inputStream.close(); To retrieve image,here is the snippet
ResultSet resultSet = stmt.executeQuery("select image from mytable'");
if (resultSet.next())
byte[] image1 = resultSet.getBytes("image");
FileOutputStream fos=new FileOutputStream("c://splash11.jpg"); //will retrieve bytes and create a file
//by the name specified
fos.write(image1);
-Amol -
**URGENT : signed applet still doesn't get full permissions**
I've bought a Microsoft Authenticode certificate with which I signed a CAB file containing my class files...
On a client machine, the browser detects security stuff but even when one acknowledges, the applet still doesn't get the permission, for instance, to open a directory for reading... a SecurityException is thrown as if the applet was not signed.
Have I forgotten something or did another one wrong ?? Must I set the Security Manager to null ????
It's really urgent, so please reply asap !!!
Thanks,
R�gis KuckaertzJust signing the applet doesn't give it any permissions. You have to assert whatever permissions you want. For example:
import com.ms.security.*; // need dummy classes to compile for non-MS
// check if we are in the MS JVM
if (Class.forName("com.ms.security.PolicyEngine") != null)
// Assert all Permissions
PolicyEngine.assertPermission(PermissionID.SYSTEM);
catch (Throwable cnfe)
System.out.println("Microsoft JVM permissions not asserted.");
System.out.println(cnfe.getMessage());
} -
Pls answer my three questions: custom install : web cache applet support: Urgent
we are using 9iAS v 10200 in win2000 server.
Here are my queries:
1: Does 9iAS v 10200 support custom installation ? For example I
want to install only web server,webcache,forms & reports support.
If custom installation of individual components is not available
on v 10200 then in which version it is supported ?
2. whenever I try installs 9iAS v 10200 from network,then after
rebooting(during start of installation)it gives JRE error. is
this a limitation of 9iAS v 10200 ?
3. 9iAS v 10200 web cache does not support applet. In which
version of 9iAS web cache would support applet ?
Its urgent. Thanks in Advance
yogeshCustom installation is not supported for iAS but we have four
different install types & you can select according to yor need
these are all available with iAS10221 onwards.You check for
installation docs related to the version you are using. -
Clustered Servers and Applet (Very URGENT Please)
Hi,
I'm using win2k/CF application server 4.5/IPlanet web server/NN4.79/JRE1.4.1/.
I have an applet in one of my web page which downloads a file from the web server(stored in http://www.abc.net/doc/zip directory on the server).
Now when I run this code on the development server, everything works fine.
But in production environment, we have 3 clustered web servers controlled by a controller (Local Cisco Director) machine. The applet code looks like this:-
strURL = "http://www.abc.net/doc/Zip/"; //the URL from which the zip is to be downloaded. Basically it hits the Controller first
strZipFileName=getParameter("zipFileName");
strURL = strURL+strZipFileName;
//Get Connection to Server and Download the file
try{
objUrl = new URL(strURL);
httpCon = (HttpURLConnection) objUrl.openConnection();
//DownLoad the File
InputStream fileInputStrm = httpCon.getInputStream();
// create a file object which will contain the directory structure to copy in the local machine
localZipFile = new File(strLocalFilePath+strZipFileName);
FileOutputStream fileOutStrm = new FileOutputStream(localZipFile);
int ch;
while ((ch = fileInputStrm.read()) != -1) {
fileOutStrm.write(ch);
// Close the InputStream, HTTP connection , File stream
fileInputStrm.close();
httpCon.disconnect();
fileOutStrm.close();
Now when the home page of the site is loaded it makes the connection and controller redirects this request to one of the web servers (say 1) which is least loaded.
Now when the applet is loaded, the new connection is established to the controller and it may redirect the request to any one of the 3 web servers (not necessarily to 1 which is required). Now sometimes it hits the right web server on which the required zip file is stored, and sometimes it doesn't hit the correct server.
Any clue what we can do in this scenario so that the applet downloads the correct file from the right server?
Please help it is very urgent....
ThanksDid you ever get a response to this or figure out how to run in a clustered environment? I am now running into the same issue and would be interested in whatever you learned.
Maybe you are looking for
-
3 monitors on a mac pro 4.1
Hello In trying to run 3 monitors on a mac pro 4.1, I have recently bought a Radeon 5870 card from Apple as advised by a 'genius' at the local apple store. This setup does not work, even giving worse performance than the 4770 with 2 of the monitors (
-
Why Does Photoshop Sometimes Think A Raw File is Already Open?
I'm doing some R&D where I'm opening the same Canon .CR2 raw file multiple times, experimenting with different converter settings. Sometimes I can open multiple documents in succession from the same raw file, in which case the documents are named e.g
-
My iPod (click wheel/no color) won't connect. It connects then disconnects. It all started when I was shopping. I started a song and was browsing around. Then it stopped. I picked another song and it skipped every song. I once had this problem with p
-
Is Custom Style Sheet Working?
I'm trying to use a custom style sheet, in order to block ads, but I don't think it works in this version of Safari. (on OS X 10.4, I use a custom CSS file and it works great.) In the Windows beta, it does nothing. I even tried a simple custom style
-
I added Edit Preferences Quiz Pass or Fail If Passing Grade Go to the next slide
Unfortunately, it doesn't work. The playback frame stays on the quiz reporting page. Please, can anybody tell me what I could be doing wrong?