Solved

java applet in Opera not sending POST values

Posted on 2008-10-26
6
622 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 60

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 60

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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

626 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