Solved

java applet in Opera not sending POST values

Posted on 2008-10-26
6
621 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
Independent Software Vendors: 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

734 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