Solved

java applet in Opera not sending POST values

Posted on 2008-10-26
6
616 Views
Last Modified: 2013-12-29
This JavaApplet method is suppose to send some POST variables to a PHP script and listen for response.
Works fine in FireFox.
In opera even though it is able to get response from PHP, PHP never gets any of the POST variables.

How can i fix that.
Applet is called through
<applet name="RegisterInstallation" code="UserRegister.class" height="251" width="271"></applet>

I never thought java applets would act differently among browsers.

Thank you.
private void sendUserInfo(String userName, String userPassword, String macAddress) {
        try{
        
        // construct data
        String data = URLEncoder.encode("UserName", "UTF-8") + "=" + URLEncoder.encode(userName, "UTF-8");
        data += "&" + URLEncoder.encode("Password", "UTF-8") + "=" + URLEncoder.encode(userPassword, "UTF-8");
        data += "&" + URLEncoder.encode("MAC", "UTF-8") + "=" + URLEncoder.encode(macAddress, "UTF-8");
        
        // Send data
        URL url = new URL(this.registerLocation);
        URLConnection conn = url.openConnection();
        conn.setDoOutput(true);
        OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
        wr.write(data);
        wr.flush();
    
        // Get the response
        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String line;
        while ((line = rd.readLine()) != null) {
            processServerMessage(line);
        }
        wr.close();
        rd.close();
      } catch (Exception e){
      }
    }

Open in new window

0
Comment
Question by:AlexanderR
  • 3
  • 2
6 Comments
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 22810063
See if this helps (Opera uses JRE from system instead of plug-in):
http://www.opera.com/support/search/view/375/
0
 
LVL 11

Author Comment

by:AlexanderR
ID: 22811565
I see the difference. Interesting.

But it still does not answer my queston as to why POST data send would not work.  
I am really new to java and not sure where to begin looking.   How can I rewrite this method propperly so it works the same in both applet (non-opera) and JRE direct call (opera)?

Thank you.
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 22812002
Following the instructions to set the JRE for Opera, see which version is configured there and then check with JRE is active for use in the Java Plugin.  Can also check the security settings while in the Opera settings.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Accepted Solution

by:
rrz earned 500 total points
ID: 22813689
You could try dressing up your request. Maybe it will help.
HttpURLConnection httpURLConnection =(HttpURLConnection)url.openConnection();
then try some or all of these lines.
httpURLConnection.setUseCaches(false);
httpURLConnection.setInstanceFollowRedirects(false);
httpURLConnection.setAllowUserInteraction(false);
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
0
 
LVL 11

Author Comment

by:AlexanderR
ID: 22822597
That does it!
0
 
LVL 11

Author Closing Comment

by:AlexanderR
ID: 31510177
Works just the way it should!  Thanks a lot.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
use lov values 2 71
null output 3 42
pagenation logic how it is working in my code 1 69
Is there a simpler dropbox system? 10 44
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This video teaches viewers about errors in exception handling.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question