pleasure
asked on
Calling a servlet from java program...
hi,
I'm using JRUN 3.0 as my app. server, I have class called DBManager which will handle transaction to database server. My servlet can work correctly with this class but when i call this class from my java program, it'won't work...
The error occured in my contructor which is look like below.
public DBManager(String disDsn) throws Exception {
dataSourceName = disDsn;
initialcontext = new InitialContext();
disDataSource = (DataSource)initialcontext .lookup ("java:comp/env/jdbc/" + disDsn);
}
when i init this class from my java program, i got this error message :
<<Need to specify class name in environment or system property, or as an applet parameter, or in an appication resource file: java.naming.factory.initia l>>
please guide.. FYI, i'm new in java...:-)
thanks for your time..
I'm using JRUN 3.0 as my app. server, I have class called DBManager which will handle transaction to database server. My servlet can work correctly with this class but when i call this class from my java program, it'won't work...
The error occured in my contructor which is look like below.
public DBManager(String disDsn) throws Exception {
dataSourceName = disDsn;
initialcontext = new InitialContext();
disDataSource = (DataSource)initialcontext
}
when i init this class from my java program, i got this error message :
<<Need to specify class name in environment or system property, or as an applet parameter, or in an appication resource file: java.naming.factory.initia
please guide.. FYI, i'm new in java...:-)
thanks for your time..
ASKER
hi pepenieto,
thanks for your response, as i said before..i'm new in java..can u explain more about your solution...:) or is there any link for me so that i can study about it...
thanks again..
thanks for your response, as i said before..i'm new in java..can u explain more about your solution...:) or is there any link for me so that i can study about it...
thanks again..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi pepenieto,
i'm trying out your solution.. let you know the outcome later... thanks anyway...
i'm trying out your solution.. let you know the outcome later... thanks anyway...
ASKER
hi,
i try another approach to call servlet..
i found this code from other question posted here...
The code is as follow..
/************************* ****/
ObjectInputStream is;
URL url;
HashMap hash = new HashMap();
try {
url = new URL("http://myserv/myApp/servlet/HelloServlet");
URLConnection urlConn = url.openConnection();
is = new ObjectInputStream(url.open Stream());
hash = (HashMap) is.readObject();
System.out.println(hash);
} catch (Exception e) {
e.printStackTrace(System.e rr);
}
/************************* ****/
but when i run this java program, i got error
<<
java.io.StreamCorruptedExc eption: InputStream does not contain a serialized object
at java.io.ObjectInputStream. readStream Header(Unk nown Source)
at java.io.ObjectInputStream. <init>(Unk nown Source)
at SDataExtraction.main(SData Extraction .java:59)
>>
can anyone tell me why?? thanks
i try another approach to call servlet..
i found this code from other question posted here...
The code is as follow..
/*************************
ObjectInputStream is;
URL url;
HashMap hash = new HashMap();
try {
url = new URL("http://myserv/myApp/servlet/HelloServlet");
URLConnection urlConn = url.openConnection();
is = new ObjectInputStream(url.open
hash = (HashMap) is.readObject();
System.out.println(hash);
} catch (Exception e) {
e.printStackTrace(System.e
}
/*************************
but when i run this java program, i got error
<<
java.io.StreamCorruptedExc
at java.io.ObjectInputStream.
at java.io.ObjectInputStream.
at SDataExtraction.main(SData
>>
can anyone tell me why?? thanks
- Context.PROVIDER_URL (connection url to your app server)
- Context.SECURITY_PRINCIPAL
- Context.SECURITY_CREDENTIA
- Context.INITIAL_CONTEXT_FA