Results 1 to 8 of 8
- 12-04-2008, 12:18 AM #1
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
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 :p
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...
- 12-04-2008, 12:39 AM #2
Welcome...
Some helpful links:
- Java:
- Commmunications:
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- Java:
- 12-04-2008, 11:44 AM #3
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
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:
Can I do something like this?Java Code:URL requestHandler = new URL("htp://mydomain.com/scripts/applet/requestHandler.php");
Java Code:URL appletLocation = *get the location of the applet*; URL requestHandler = new URL(appletLocation, "requestHandler.php");
Last edited by barr; 12-04-2008 at 02:46 PM.
- 12-04-2008, 04:04 PM #4
Java 2 Platform SE 5.0 look at the getPath(), getHost() etc methods. I think those may be what you want
- 12-05-2008, 11:41 AM #5
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
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:
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.Java 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); } }
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?
- 12-08-2008, 04:19 PM #6
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?
- 12-11-2008, 11:08 AM #7
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
Thanx, I found out that contentPanel.validate() solved my problem.
- 12-11-2008, 11:14 AM #8
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
I've come to the point where a can send and recieve http-requests, but I'm doing something wrong.
info.php checks if "id" and "filename" is posted, but it says that only "id" is posted.Java 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--
Can you see what I've done wrong?
Similar Threads
-
Project Help
By XxHEXSORxX in forum AWT / SwingReplies: 4Last Post: 01-28-2009, 10:01 AM -
Help With Project!!!
By jackhammer in forum New To JavaReplies: 5Last Post: 12-04-2008, 05:10 AM -
Java newb Q: 8-digit id
By 1111FM in forum New To JavaReplies: 2Last Post: 09-29-2008, 02:37 PM -
Newb Topics
By dkizzy in forum New To JavaReplies: 2Last Post: 09-17-2008, 07:01 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks