?
Solved

URL Connection

Posted on 1997-11-14
3
Medium Priority
?
181 Views
Last Modified: 2010-04-16
I am a student and I'm engaged with the dissertation at the moment.The actually problem of my work is the following:
A web-server camera is installed local over a Hub with a PC.
In the camera(an AXIS Product) is a relay. In a Browser I can simply switch the relay by input the URL :
http://cameraname/io/relayon.txt

My question:How can I switch the relay from a Java Applet?

I've tried it like this:


private synchronized void reopenURL( URL urlOpen )
{
    try
    {
      URLConnection connect = urlOpen.openConnection();
             
      connect.setDefaultAllowUserInteraction( true );
                        
        connect.setUseCaches( false );

      connect.setDoInput( true );       

      connect.connect();

      InputStream inputstream = connect.getInputStream();

      while( inputstream.read() >= 0 );
             inputstream.close();
        }
      catch( IOException e )
      {
            String m_strIOExcept = e.getMessage();
      }
}

public void setRelayOn()
{
        try
      {
      
       URL url = newURL("http","webcam",80,"/io/input.txt");
       reopenURL(url);
}
      catch (MalformedURLException m)
      {
            String test = m.getMessage();      
      }
            
This is my own written class (not exactly of course)
The method setRelayOn() is called by the Applet.
If I debug the program there is the same mistake every time.
When I reach the line connect.connect() I receive the error message "java/net/URLConnection: field url not found"!

Thanks for your help.
0
Comment
Question by:mkaufman
[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
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
russgold earned 400 total points
ID: 1230588
If you can normally do what you want from a browser using http, just call showDocument() on your applet context:


URL cameraSwitch = new URL( "http://cameraname/io/relayon.txt" );
getAppletContext(). showDocument( cameraSwitch );
0
 

Author Comment

by:mkaufman
ID: 1230589
I,ve tried it and it works!!!!
thank you very,very much!!!!!
0
 

Author Comment

by:mkaufman
ID: 1230590
In your example, how can I prevent, that the Browser use caches?
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

762 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