Quang Pham

Ranch Hand
+ Follow
since Nov 29, 2005
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 Quang Pham

Hi
Can some one show me how to write a java program to download a file from a secure server https?
url=https://www.fededirectory.frb.org/FedACHdir.txt
Currently I am able to download file from http but got certificate issue when trying to download from https.
Here is the code:
-----------
public static void main(String args[]) throws IOException {
java.io.BufferedInputStream in =
new java.io.BufferedInputStream(
new java
.net
.URL("https://www.fededirectory.frb.org/FedACHdir.txt";).openStream());
java.io.FileOutputStream fos =new java.io.FileOutputStream("c:/bankInfo.txt");
java.io.BufferedOutputStream bout = new BufferedOutputStream(fos, 1024);
byte[] data = new byte[1024];
int x = 0;
while ((x = in.read(data, 0, 1024)) >= 0) {
bout.write(data, 0, x);
}
bout.close();
in.close();
System.out.println("File Downloaded");
}
-----------
Thanks
9 years ago
Hi friends
It's sad, Head First EJB is not to be upgrade to J2EE 5. Now I am not sure what book is best for preparing the SCBCD J2EE 5 Certification. I have finish Head First EJB but still need some more study before I can take the test. Please give me a sugession.
Thanks for your advice.
Quang

[ November 16, 2008: Message edited by: Quang Pham ]
[ November 16, 2008: Message edited by: Quang Pham ]
Hi Jeanne
Thank you so much for pointing me to the right direction. I'll find some book to finish my SCBCD study.
Thanks again
Quang
Hi
You can laugh as much as you want. The Head First EJB is a study material for SCBCD J2EE 1.3. I studied the Head First EJB for a little over two years and I came to testing site for exam just yesterday. To my surprise the test was not as I expected. It was SCBCD J2EE 5, which I did not pay attention to when I registered for the test. You can guess, I've failed the test.
Any one know what is happenning to the SCBCD testing version J2EE 5, J2EE 1.3, J2EE 1.4 etc...?
Thanks
Quang
Hi Riyad
It is very nice to own a copy of MyEclipse. By the way, It's wonderful to know you.
Thanks for stopping by.
Quang
Paul
I am currently studying HF EJB and this is one of my questions. You have given us a very clear answer.
Thank you.
Hello Elliotte,
I have learned and coded a lot of HTML in the past few years. What will benefit me for going back and read Refactoring HTML?
Thanks
Quang
Hi
Can some one explain the following code:

boolean a = false;
boolean b = false;
boolean c = false;

public boolean isOptionValid(){
return a||b||c;
}

Thanks
13 years ago
Hi Mike
Thanks for helping me. But it's still confusing because we got Struts Framework with EJB 1.1

What code should I put inside my Action class that enable me to get the SessionContext?

protected MY_TO invokeService(MY_TO myTO)
throws EJBException, RemoteException, NamingException, CreateException {
SeparationReasonInquiry_TO sepReasonTO =
(SeparationReasonInquiry_TO) myTO;
InitialContext ctx;
if (home == null) {
ctx = new InitialContext();
Object o = ctx.lookup("java:comp/env/PilotFacade");
home = (PilotFacadeHome) PortableRemoteObject.narrow(o, PilotFacadeHome.class);
}
PilotFacade remote = home.create();
myTO =
(MY_TO) remote.processTransaction(
"SeparationReasonInquiry",
sepReasonTO);
return myTO;
}
[ November 15, 2007: Message edited by: Quang Pham ]
Hi
Head First EJB - EJB Transactions - Page 480
The book showing how to get to the UserTransaction using EJBContext.
But where can I get the EJBContext?
My first guess is: if I can get hold of the SessionContext I'll be able to get to UserTransaction.
I am stuck right here.
Please help.
Thanks
Quang

[ November 15, 2007: Message edited by: Quang Pham ]
[ November 15, 2007: Message edited by: Quang Pham ]
Hi Kirba
Have you got it to work? I have the same question as you do. Let me know how you got it done.
Thanks
Quang
14 years ago
Hi Hung
You can only store 1 frmTime, 1 typeMsg and 1 byte[] data per instance Message. I've shorten your data and modified the source code as follow and it works.
import java.io.BufferedReader;
import java.io.FileReader;
public class TestMessage {
private String filePath;
public void readFileMsg(Message msg) {
String line = null;
try {
String[] info = {"9:10:05","Long Message","030000002f130200000000000800450000800000000001119f7a0a000000e0e02f13c5dac5da006c0000000000000303000000000 00400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000"};
msg.setFrmTime(info[0]);
msg.setTypeMsg(info[1]);
msg.setData(info[2].getBytes());
System.out.println(msg.getFrmTime());
System.out.println(msg.getTypeMsg());
byte b [] = msg.getData();
for (int i=0;i< b.length;i++){
char c = (char)b[i];
System.out.print(c);
}
} catch (Exception e) { // TODO: handle exception//
e.printStackTrace();
}
}
public static void main(String[] args) {
Message msg = new Message();
TestMessage testMsg = new TestMessage();
testMsg.readFileMsg(msg);
}
}
14 years ago
Hi Hung
It should work by changing your code like this:
while ((line = in.readLine()) != null) {String[] info = line.split(";");msg.setFrmTime(info[0]);msg.setTypeMsg(info[1]);
msg.setData(info[1].getBytes()); <-----------------
System.out.println(msg.toString());
}
But it seem like your data contains a bunch of PACK fields. To understand your data is another story.
Quang
14 years ago
Hi
The int variable in your isStack interface class is final by default. Therefore it must have a value.
Quang
14 years ago