Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-04-2008, 01:18 AM
Member
 
Join Date: Dec 2008
Posts: 5
Rep Power: 0
barr is on a distinguished road
Default Help with newb-project much appreciated
Hi, I'm quite new to java and have never done any applets before.

Now I need to create a fileupload-applet för my webpage. I guess I'm into some serious learning by trial-and-error and I need it done by 12/12

Anyhow, I've managed to get a HelloWorld applet up and running, and now I need to learn how to communicate with servers and send files. A google search mostly ends up in ads for fileupload-applets, so I thought I'd try this forum out.

Is there any good tutorials for java/server communications, or can anyone here show me some examples?

The book I've got, Java Software Solutions, does unfortunately not adress these things...
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 12-04-2008, 01:39 AM
CJSLMAN's Avatar
Moderator
 
Join Date: Oct 2008
Location: Mexico
Posts: 1,159
Rep Power: 3
CJSLMAN is on a distinguished road
Default Welcome...
Some helpful links:Luck,
CJSL
__________________
Chris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-04-2008, 12:44 PM
Member
 
Join Date: Dec 2008
Posts: 5
Rep Power: 0
barr is on a distinguished road
Default
Thank you, I wasn't aware of that sun had those basic tutorials. Neat.

Question: Is there a way for the applet to know it's location on the server?

For example, the applet is located at "htp://mydomain.com/scripts/applet/", and I want to connect with a php-file in the same folder.

So instead of:

Code:
URL  requestHandler = new URL("htp://mydomain.com/scripts/applet/requestHandler.php");
Can I do something like this?

Code:
URL appletLocation = *get the location of the applet*;
URL requestHandler = new URL(appletLocation, "requestHandler.php");

Last edited by barr; 12-04-2008 at 03:46 PM.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-04-2008, 05:04 PM
xcallmejudasx's Avatar
Senior Member
 
Join Date: Oct 2008
Location: Houston, TX & Flint, MI
Posts: 585
Rep Power: 2
xcallmejudasx is on a distinguished road
Send a message via AIM to xcallmejudasx
Default
Java 2 Platform SE 5.0 look at the getPath(), getHost() etc methods. I think those may be what you want
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 12-05-2008, 12:41 PM
Member
 
Join Date: Dec 2008
Posts: 5
Rep Power: 0
barr is on a distinguished road
Default
Originally Posted by xcallmejudasx View Post
Java 2 Platform SE 5.0 look at the getPath(), getHost() etc methods. I think those may be what you want
Thanks, I found the getCodeBase() that seems to be what I want.

*********************

Now I'm working with the interface, and I have a problem with the following code:

Code:
public class gallery{
		JLabel title = new JLabel("Gallery");
		public void show(){
			contentPanel.removeAll();
			contentPanel.add(title, BorderLayout.NORTH);
			contentPanel.add(text, BorderLayout.CENTER);
			
		}
	}
	
	public class uploader{
		JLabel title = new JLabel("Uploader");
		public void show(){
			contentPanel.removeAll();
			contentPanel.add(title, BorderLayout.NORTH);
			contentPanel.add(text, BorderLayout.CENTER);
			
		}
	}
I have two buttons, one for uploading and one for browsing. The event handlers for the buttons sets the JLabel text to a string returned from a php-page that returns time(), and calls uploader.show() resp. browser.show(), that clears the contentPanel and adds it's own content.

However, the JLabel title only changes the first time I press a button, if I first press the button "upload", the title changes to Uploader, and if I then press "Browse", the title changes to "Gallery". But after that, the title don't change anymore. But the JLabel text change each time I press a button.

How can this be?
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 12-08-2008, 05:19 PM
xcallmejudasx's Avatar
Senior Member
 
Join Date: Oct 2008
Location: Houston, TX & Flint, MI
Posts: 585
Rep Power: 2
xcallmejudasx is on a distinguished road
Send a message via AIM to xcallmejudasx
Default
I'm not familiar with JLabel or contentPanel but I think it may be something to do with add. Is there a set or clear method available? The way I picture any add method working is to actually add some object, not just change the text of the object, which is why I think you may need to contentPanel.set() or something.

Have you tried clearing the title right after the button is pressed and then re-writing the title again over it?
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 12-11-2008, 12:08 PM
Member
 
Join Date: Dec 2008
Posts: 5
Rep Power: 0
barr is on a distinguished road
Default
Thanx, I found out that contentPanel.validate() solved my problem.
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 12-11-2008, 12:14 PM
Member
 
Join Date: Dec 2008
Posts: 5
Rep Power: 0
barr is on a distinguished road
Default
I've come to the point where a can send and recieve http-requests, but I'm doing something wrong.

Code:
POST /info.php HTTP/1.1
Host: mypage.com
Connection: Keep-Alive
Content-Type: multipart/form-data; boundary=gismoquack
Content-Length: 158


--gismoquack
content-disposition: form-data; name="id"

user
--qismoquack
content-disposition: form-data; name="filename"

test.jpg
--qismoquack--
info.php checks if "id" and "filename" is posted, but it says that only "id" is posted.

Can you see what I've done wrong?
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

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

BB 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
Project Help XxHEXSORxX AWT / Swing 4 01-28-2009 11:01 AM
Help With Project!!! jackhammer New To Java 5 12-04-2008 06:10 AM
Java newb Q: 8-digit id 1111FM New To Java 2 09-29-2008 03:37 PM
Newb Topics dkizzy New To Java 2 09-17-2008 08:01 AM
Converting an existing project to an EclipseME project JavaForums Java Blogs 0 06-23-2008 10:41 AM


All times are GMT +2. The time now is 01:00 PM.



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