Solved

java applet in Opera not sending POST values

Posted on 2008-10-26
6
597 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now