Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

java puneri

Greenhorn
+ Follow
since Jun 04, 2001
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 java puneri

Thanks Tim.

puneguy
18 years ago
Java gurus requested to comment
We are not using Servlet,JSP.
As of now we are using the mysql's Thin driver, for applet-database connection.
Now we are facing firewall problem, we tried to solve this problem using some server residing .exe file which will respond to applets query.
It means the information need by applet client will be sent to this specific server residing .exe file
code somthing like ...
URL url = new URL("http://hostname/exefile-name,param1,param2);
In turn the server program will send information to applet client in some known format, e.g. XML.

If anybody already worked on such kind of communication are requested to comment & discuss.
Thanks in advance
Puneguy
18 years ago
Hi
To show a HTML page from applet we use
getAppletContext().showDocument(url,target);
url = location path of html page to be shown!
target = _self = same window
_blank = new window
refer jdk help regarding showDocument!
May you try this which eventhandling of button !
Careful while creating URL object. It should be created using
getCodeBase();

Cheers
PuneGuy
19 years ago
hi
Following code is for achiving double buffering !
----------------------------------------------------------------
code starts
Image buffer;
Graphics g1;
public void update(Graphics g){
paint(g);
}

public void paint(Graphics g){
//Draw the flickering code
drawExample();
// Draw completed buffer to g
g.drawImage(buffer,0,0,this);
}
public void drawExample(){
buffer = createImage(APPLETWIDTH,APPLETHEIGHT);
g1 = buffer3.getGraphics(); /// Offline Image drawing
g.setColor(whateverulike);
g.drawLine();
g.drawRect();
. /// Carry on drawing all here
.// draw entire stuff that u are drawing in paint method
.
// u r done here drawing all stuff
return;
}
Code ends !!!
-----------------------------------------------------------

I tried to explain what I had understood from your post.
If still have problem then feel free to ask !
or better you explain your problem in detail !
Cheers
PuneGuy
19 years ago
Hi
If you are using AWT instead of SWING then you have to use
double buffering which avoids flickering.
little bit more:-
1.Draw whatever you wanto on offline Image object.
2.When you are done show that Image object on the applet canvas
Cheers
PuneGuy !
19 years ago
Hi kajol :P
Hope Math.ceil(doubleVal) works for you !
:P
19 years ago
hi

use Math.ceil(doublevalue);

PuneGuy !
19 years ago
Hi
this may help you
-------------------------------------
Start Of Code
URL fileURL = null;
String filename = "readme.txt"
// Get File URL
try{
fileURL = new URL(getCodeBase(),filename);
}catch(MalformedURLException e){
getAppletContext().showStatus(e.toString());
}
String readLine="";
Vector data=null;
//Read the FILE
try{
BufferedReader aReader = new BufferedReader(new
InputStreamReader(fileURL.openStream()));
while((readLine = aReader.readLine())!= null){
data.addElement(readLine);
}//end of while
aReader.close();
}catch(IOException e){
getAppletContext().showStatus(e.toString());
}
// process the vector to retrive the information....
End of Code
----------------------------------------------------------------

Play around to get thru !
dont give filename as hardcoded path .
i.e. e.g "C:\data\readme.txt" =========> should be avoided !

Cheers
PuneGuy !
19 years ago
Yes we can do this with jdk1.1 using Graphics.
Simply draw the tree on Image object, then show this object on applet canvas.
Means for [+] you have to draw two lines vertical & horizontal & square around it!
Cheers!
PuneGuy !
19 years ago
hi Deepak
I am sorry I can't send you any code for some reson as you understand!
I can tell you brief here !
following function should be there in SERVLET
I will call the following function from the doGet or doPost method of the servelt.
-------------------------------------------------------
public void senddata(HttpServletResponse response,String data){
ObjectOutputStream outputToApplet = null;
try{
outputToApplet = new ObjectOutputStream(response.getOutputStream());
outputToApplet.writeObject(data);
outputToApplet.flush();
outputToApplet.close();
}catch(Exception e){
System.out.println("MyServlet: senddata() "+e.toString());
}
}
----------------------------------------------------------------
Let me explain!
String data in parameter of the above method is the data to be sent to applet.
We are sending the object so it could be anything like StringBuffer,ResultSet etc.
Thats servlet part over!
_________________________________________________________________
Applet part!:-
public Vector getdatafromServlet(){
ObjectInputStream inputFromServlet = null;
try{
URL servletURL = new URL(servletLocation);
URLConnection servletConnection = servletURL.openConnection();
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
servletConnection.setUseCaches(false);
servletConnection.setDefaultUseCaches(false);
servletConnection.setRequestProperty("Content-Type","application/octet-stream");
inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
String resultdata = (String)inputFromServlet.readObject();
inputFromServlet.close();
}catch(ClassNotFoundException e){
}
catch(Exception e){
}
finally{
return resultdata;
}
}
----------------------------------------------------------------
In above function servletlocation is the url where servelt is located.
Just check out for returntype of inputFromServlet.readObject();
(I used Vector)

________________________________________________________________

I implemented the above communication I was through this So it has to work. Play around the code.
I found the above code Internet only so if you search a little bit more you will get the zip of the source code. Javawebserver 2.0 has this example!, Even you will find example in BEA weblogic server I Guess. I am sure about JWS2.0 Example.
BEST OF LUCK !
Further need assistance, I will help you ! But can't send any code to you.
19 years ago
Browser JVM doesn't have any table component for applet. (Swing can be use But client will need a 10 MB Plugin to be download first time!)
You can actually draw the table using graphics. I have done same stuff !
Use doublebuffering to avoid the flickering !
feel free to contact !
Cheers !
puneGuy !
19 years ago
you have to modify your applet.HTML file to download the swing plugin from sun.com site automatically.
I know one tool 'HTMLConverter' which converts your html file to require syntax. This tool is available on internet, Search in google search engine.
puneguy !
19 years ago
There are lots of techniques through which you can make applet accessing (server residing)database.
Applet can access database through http protocol.
1.Use thin drivers if server has specific ports opened for outside world. (these drivers are available on net. )
2.Use servlet to do your database part, communicate with servlet to retrive data.
3.Write any server program & implement HTTPTunneling & decide your own tags to communicate to server program!
4.There is one more method, applet can access database using RMI communication too. I will not recommend this anyway.

PuneGuy !
19 years ago