Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-07-2008, 10:04 AM
Moderator
 
Join Date: Nov 2007
Posts: 1,637
Java Tip will become famous soon enoughJava Tip will become famous soon enough
Reading a file from Applet (BufferedReader)
The code snippet below presents an applet that reads an file and displays its contents on the console of the server.

Code:
import java.applet.*; import java.net.*; import java.io.*; public class MyApplet extends Applet { public void init() { readFile("mydatafile.txt"); } public void readFile(String f) { try { String aLine = ""; URL source = new URL(getCodeBase(), f); BufferedReader br = new BufferedReader (new InputStreamReader(source.openStream())); while(null != (aLine = br.readLine())) { System.out.println(aLine); } br.close(); } catch(Exception e) { e.printStackTrace(); } } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-22-2008, 11:51 PM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 424
Nicholas Jordan is on a distinguished road
persist return from applet on server
This is too close to where I am at on my primary project, I have to avail myself of potential help here. After long - slow drudgery in beginner issues, I was recently writing servlet code and JSP -> I figured the jsp could talk to the servlet reasonably well. I reasoned that an applet could be an effective defense barrier at which "At least the respondent is thinking..." could be used to reduce the authentication workload to either authorized access or intrusion attempts that were actually worth logging and trapping. After finding the get call that allows reading of the responses from the client ( browser ) using forms and url's, ... I just sorta relaxed and started helping others hoping to gain enough knowledge along the way to get an applet to talk to a Servlet / JSP combination. I had pretty well saturated my available mind loading.

Several questions if I may:

Where is getCodeBase(); a member of base class Applet?
We open an InputStreamReader, but where are we? -> on the server or on the client? It looks like full Duplex has been replaced with a Dimensionless communicatons protocol where reads and write()'s ....? I see that we are in an Applet, which run client side .... I thought.

These may sound beginerish coming from someone who can do Threads, but this is actually what I see when I look at the code. I could do a lot with this code if I can get this <- || -> || <- || coming or going figured out. Assume I am trying to get the Applet to send some Base-64 encoded raw to the server so that only verbally transferred knowledge about the Applet and it's behaviour allow an otherwise unannounced respondent to request the actual authentication protocol.

That will be hardcoded in the Servlet.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Applet - reading text files packed into JAR file Java Tip Java Tips 0 02-08-2008 10:15 AM
Reading file contents (BufferedReader) Java Tip Java Tips 0 02-07-2008 10:00 AM
Reading int values using BufferedReader Java Tip Java Tips 2 01-24-2008 08:26 PM
Reading text from a URL using BufferedReader Java Tip Java Tips 0 12-26-2007 11:17 AM
Reading an ASCII file (BufferedReader) JavaForums Java Blogs 0 11-02-2007 10:12 PM


All times are GMT +3. The time now is 09:45 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org