Karen Gomes

Ranch Hand
+ Follow
since Aug 25, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Karen Gomes

Hello,

I have a SingletonClass1 in one project of which some features I reuse in a 2nd project.

SingletonClass1:
some common methods
some common attributes
other methods/attributes

SingletonClass2:
some common methods from SingletonClass1
some common attributes SingletonClass1
other methods/attributes

However since I cant inherit from Singletonclass1, how do I resolve this issue? I can set Project1 as a dependency/library in project2.
So I wan to reuse this SingletonClass1.

I can refactor this code, however lot of code in Project1 and other projects use this SingletonClass1. So I want to make sure I use the best approach here.

Thanks!
Thanks for your prompt reply Ernest. Your explanation was really very good.

I really appreciate your time and help!!!

Thanks
Karen
18 years ago
Hello friends,

I am trying to reinitialize my already existing list and use a list.clear() method to clean up a list before I push in new values into it and set the map based on the values in the list.
My output for the below code is:
-----1A-------- [first value, second value]
-----1B-------- [third value, fourth value]
PS: Both times I try to check if the map still holds the correct values which is where the code is breaking.

This same code works perfrctly fine if I replace the line
initList.clear(); by
initList = new ArrayList(3);

CORRECT OUTPUT:
-----1A-------- [first value, second value]
-----1B-------- [first value, second value]

Here's the code I'm running:

//============================================================
import java.util.*;

public class myTests {
static final Map testMap = new HashMap(2);

public static void main(String[] args) {
testLists();
}

public static void testLists(){

List initList = new ArrayList(3);
initList.add(new String("first value"));
initList.add(new String("second value"));

testMap.put("01", initList);
System.out.println("-----1A-------- "+ (List)testMap.get("01"));
initList.clear();
//initList = new ArrayList(3);

initList.add(new String("third value"));
initList.add(new String("fourth value"));
testMap.put("02", initList);
System.out.println("-----1B-------- "+ (List)testMap.get("01"));

}
}

Why does this List behave so? Pls help? Is there a better way to resolve this than create new objects everytime?

Thanks
Karen
[ February 02, 2006: Message edited by: Karen Gomes ]
18 years ago
Hello Friends,

I'm very new to struts, and have a code piece that does the following:

<logic:iterate id="paramData" name="<%=printParam%>" >
<PARAM NAME = "<bean:write name="paramData" property="key" />" VALUE="<bean:write name="paramData" property="value" />">
<PARAM NAME = "rootUrl" VALUE="<%=HttpUtil.getServerUrl(request)%>" >
</logic:iterate>

It iterates through a Map and gets the values in the applet. However I now have to change this so that it gets the applet params from a ParamsVO.java, a value object. How does the code change to get the values now?
I have paramsvo.getXXX methods that I can use. Though not sure how they are used with struts. Pls help!!

Karen

[ April 28, 2005: Message edited by: Karen Gomes ]
[ April 28, 2005: Message edited by: Karen Gomes ]
18 years ago
No It doesnt :-(
That was the first thing I tried.
19 years ago
Hello friends,

I found this code at
http://javaalmanac.com/egs/java.net/JarUrl.html

=================
try {
// Create a URL that refers to a jar file on the net
URL url = new URL("jar:http://hostname/my.jar!/");

// Create a URL that refers to a jar file in the file system
url = new URL("jar:file:/c:/almanac/my.jar!/");

// Get the jar file
JarURLConnection conn = (JarURLConnection)url.openConnection();
JarFile jarfile = conn.getJarFile();

// When no entry is specified on the URL, the entry name is null
String entryName = conn.getEntryName(); // null


// Create a URL that refers to an entry in the jar file
url = new URL("jar:file:/c:/almanac/my.jar!/com/mycompany/MyClass.class");

// Get the jar file
conn = (JarURLConnection)url.openConnection();
jarfile = conn.getJarFile();

// Get the entry name; it should be the same as specified on URL
entryName = conn.getEntryName();

// Get the jar entry
JarEntry jarEntry = conn.getJarEntry();
} catch (MalformedURLException e) {
} catch (IOException e) {
}

=================

I want to do the same but to a zip file. pls help!!!

Thanks
Karen
19 years ago
Hello,

I am trying to do the following:
1] download a zip file from server [hopefully in memory if possible]
2] unzip the file, and get the contents in a byte[]

I need to unzip n read contents on the client-side. Is it possible to do it w/o having a physical copy or a cached copy of the file on the client side.
Any suggestions or help with the code will be appreciated.

Thanks
Karen
[ March 25, 2005: Message edited by: Karen Gomes ]
19 years ago
Hello Friends,

I would like to know if we can pass a data structure into an applet via the applet param tag from jsp.
I found a doc [at ]http://java.sun.com/docs/books/tutorial/applet/appletsonly/paramQs.html#paramTypes] that says I can do it ... but need to confirm this beforehand.

If yes then are there any data structs that are not allowed in there?
Please advice.

Thanks
Karen
[ March 16, 2005: Message edited by: Karen Gomes ]
19 years ago
Hello friends,

I have multiple jars that I downloaded for a specific functionality. These are jars provided by a vendor and not developed by us. I have to use them in an applet to be deployed on a web server.

As of now my applet jar file [that includes the above jars] is abt 1.78 MB. How can I reduce this download time?
I got one solution to this problem at:
http://www.activetree.com/forum/viewtopic.php?t=162
But again the same question:
What if the plugin refers to the url:
http://java.sun.com/products/plugin/index.html#download
Are there any work arounds then?


Any help will be appreciated.

Thanks
Karen
[ March 11, 2005: Message edited by: Karen Gomes ]
19 years ago
Hello friends,

I'm trying to print using the javax.print API. My code works fine when I print images. However when I try to print TXT files, my code queues the file in the printer spooler. However the printer deletes the document from the queue after dispaying a "deleting printing" status in the printers queue. I tried using different sets of flavor but nothing seems to work. Also tried all the code I could find online (that works for everyone else), but did not work fine on my printer.

here is one such code [in the reply 2 of]:
http://forum.java.sun.com/thread.jspa?threadID=293692&tstart=0
======================================
I used the smartJPrint API and that worked perfectly fine on my printer for PDF. However I do not have the luxury of using external APIs and need to sort this problem.

Pls help!!!

Thanks,
Karen
[ March 03, 2005: Message edited by: Karen Gomes ]
19 years ago
I am looking for some reliable solution to print pdf from an applet,pref. using java apis. We want to avoid using external libraries, so as not to increse the download time.

Any luck with this?

Karen
19 years ago
Sorry abt missing the info on signed applet. Yes, I jar up my applet, and sign it. I had created a policy file earlier, but deleted them all now and also every other version of the applet jar on my machine but the one on the server. Also clear the Browser cache everytime.

I do get the accept/deny the certificate dialog box. Any idea what else could be going wrong?
I have created a self signed certificate using keytool, could that be a cause for it?


I still get these messages in the logs:
/// Logs when attempting to connect to localhost

java.lang.RuntimeException: access denied (java.security.SecurityPermission putProviderProperty.BC)
at com.activetree.pdfprint.AtPdfStreamPrinter$a$a.a(Unknown Source)
at com.activetree.pdfprint.AtPdfStreamPrinter.a(Unknown Source)
at com.activetree.pdfprint.AtPdfStreamPrinter.print(Unknown Source)
at activetree.pdfprint.PdfPrintFromURLApplet.start(PdfPrintFromURLApplet.java:100)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.RuntimeException: access denied (java.security.SecurityPermission putProviderProperty.BC)
at com.activetree.pdfprint.AtPdfStreamPrinter.print(Unknown Source)
at activetree.pdfprint.PdfPrintFromURLApplet.start(PdfPrintFromURLApplet.java:100)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)



/// Logs when attempting to connect to some remote site

java.lang.RuntimeException: access denied (java.net.SocketPermission www.hitmill.com:80 connect,resolve)
at com.activetree.pdfprint.AtPdfStreamPrinter$a$a.a(Unknown Source)
at com.activetree.pdfprint.AtPdfStreamPrinter.a(Unknown Source)
at com.activetree.pdfprint.AtPdfStreamPrinter.print(Unknown Source)
at activetree.pdfprint.PdfPrintFromURLApplet.start(PdfPrintFromURLApplet.java:100)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.RuntimeException: access denied (java.net.SocketPermission www.hitmill.com:80 connect,resolve)
at com.activetree.pdfprint.AtPdfStreamPrinter.print(Unknown Source)
at activetree.pdfprint.PdfPrintFromURLApplet.start(PdfPrintFromURLApplet.java:100)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
stopping...
19 years ago
I have signed the applet. Is there a way to find out what the problem is.
Also is using Java Web start the only way out of this?

Thanks
Karen
19 years ago
Hello Friends,

I'm trying to print a pdf document from an applet. I have managed to get it to the point that it detects the default [as well as all other network] printers. However, it gives me an Access Denied error, that I have no idea of how to tackle.

The url that I try to get the pdf doc from: http://shan:7001/printPDFApp/New_Test.pdf
"shan" is my machine name

Here's the Java console output:
======================================================
initializing...
starting...
pdfUrl after = http://shan:7001/printPDFApp/New_Test.pdf
initialising pdfprinter
pdfprintercom.activetree.pdfprint.AtPdfStreamPrinter@da2cef
defaultPrintService : Win32 Printer : Lexmark Z25-Z35
found printer: Win32 Printer : \\ocdc2\ALPHA
found printer: Win32 Printer : Lexmark Z25-Z35 (Copy 2)
found printer: Win32 Printer : Lexmark Z25-Z35
finally found printers: 3
printerSupportedPageFormat.getOrientation() : 1
java.lang.RuntimeException: access denied (java.net.SocketPermission shan:7001 connect,resolve)
at com.activetree.pdfprint.AtPdfStreamPrinter$a$a.a(Unknown Source)
at com.activetree.pdfprint.AtPdfStreamPrinter.a(Unknown Source)
at com.activetree.pdfprint.AtPdfStreamPrinter.print(Unknown Source)
at activetree.pdfprint.PdfPrintFromURLApplet.start(PdfPrintFromURLApplet.java:100)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.RuntimeException: access denied (java.net.SocketPermission shan:7001 connect,resolve)
at com.activetree.pdfprint.AtPdfStreamPrinter.print(Unknown Source)
at activetree.pdfprint.PdfPrintFromURLApplet.start(PdfPrintFromURLApplet.java:100)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
=====================================================================
Any help will be appreciated.

Thanks
Karen
[ February 28, 2005: Message edited by: Karen Gomes ]
19 years ago
Hello Friends,

My current application uses a properties file that works fine. However at runtime, in case there is an error, like it could not find the queue defined in the properties file then I need my app to go to a url and get properties from there, rewrite the old properties file and reload.

I'm able to read the data from the url but not sure how to rewrite the properties file. I'm using this code to read the contents from the url:




Any help will be appreciated.

Thanks
Karen
19 years ago