Jump to content

PlutoNZL

Member
  • Posts

    98
  • Joined

  • Last visited

Awards

This user doesn't have any awards

Recent Profile Visitors

915 profile views
  1. It sounds like you have terrible time management skills. Cheating isn't the answer.
  2. You posted the exact same questions a week ago. A week is more than enough time to learn the material and answer the questions.
  3. Unfortunately I don't have an Arduino so I can't run your code. I think the issue may be that your response is malformed. Update your response to be just this: if (c == '\n' && currentLineIsBlank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(); client.println("<html>"); client.println("<body>"); client.println("<a href=\"/?0\"\">Turn On LED</a>"); client.println("<a href=\"/?1\"\">Turn Off LED</a><br />"); client.println("</body>"); client.println("</html>"); break; } If that works, that shows that the issue you're getting is because of your response format.
  4. I don't know what would cause that. Can you upload your entire code?
  5. You need to use the printf method: https://docs.oracle.com/javase/7/docs/api/java/io/PrintWriter.html#printf(java.lang.String, java.lang.Object...)
  6. I haven't used IntelliJ so I can't comment about the Command Line App template, but you need one main method for each program. The main method accepts the command line arguments as a String array parameter. For example: public class FileLister { public static void main(String[] commandLineArguments) { String source = commandLineArguments[0]; String target = commandLineArguments[1]; int startingIndexOfExtensions = 2; String[] extensions = new String[commandLineArguments.length - startingIndexOfExtensions]; for (int i = startingIndexOfExtensions; i < commandLineArguments.length; i++) { extensions[i - startingIndexOfExtensions] = commandLineArguments[startingIndexOfExtensions]; } listFilesWithExtension(source, target, extensions); } static void listFilesWithExtension(String folder, String target, String[] extensions) { System.out.println("Folder: " + folder); System.out.println("Target: " + target); for (String extension : extensions) { System.out.println("Extension: " + extension); } } } You can compile this using: javac FileLister.java And run the program using: java FileLister ThisIsMyFolder ThisIsMyTarget ThisIsMyFirstExtension ThisIsMySecondExtension Which will produce the following output: Folder: ThisIsMyFolder Target: ThisIsMyTarget Extension: ThisIsMyFirstExtension Extension: ThisIsMyFirstExtension Take a look here for more information about command line arguments: https://docs.oracle.com/javase/tutorial/essential/environment/cmdLineArgs.html
  7. Look at the code in the tutorial I linked. readString is declared at the top of the file: String readString; The first 100 characters of the request string is then added to readString: //read char by char HTTP request if (readString.length() < 100) { //store characters to string readString += c; }
  8. You never declare the 'readString' variable. It looks like you expect it to the URL of the request and you are trying to check the URL parameter. You need to assign 'readString' to the URL of the GET request. Are you following a tutorial? If you give me the link I'll be able to help you a lot more. EDIT: Take a look at the tutorial here: http://www.instructables.com/id/Arduino-Webserver-Control-Lights-Relays-Servos-etc/?ALLSTEPS their code looks very similar to yours.
  9. I don't understand how your code works at all. When the user submits the form, how are you reading the response? How do you know which radio button was selected? Where are you assigning the "SET" variable?
  10. You need to use the HTTP prefix in your request URL. For example "http:///api.openweathermap.org/data/2.5/weather?id=3464008&APPID=SECRET". You don't need to set up a local server. Here's my working example: <html> <head> <script> function myFunction() { var xmlHttp = new XMLHttpRequest(); xmlHttp.open("GET", "http://api.openweathermap.org/data/2.5/forecast/city?id=524901&APPID={YOUR_APP_ID_GOES_HERE}", false); xmlHttp.send(); document.getElementById("x").innerHTML = xmlHttp.responseText; } </script> </head> <body> <p id="x"></p> <button type="button" onclick="myFunction()">Try it</button> </body> </html>
  11. If your private Class is a top level Class, it is impossible to access. Why do you need this Class to be private? If something is private it is only accessible within the Class it is defined. This means that a private Class will only be accessible by the Class that contains it. If the private Class is not contained in another Class, it is impossible to access it. Here's an example of a private inner Class being accessed by an outer Class: public class MyPublicClass { public void MyMethod() { MyPrivateClass p = new MyPrivateClass(); System.out.println(p.myPrivateVariable); } private class MyPrivateClass { public int myPrivateVariable = 1; } }
  12. All of your issues are caused by regional settings. See here on how to fix: http://www.howtogeek.com/245510/how-to-change-excels-decimal-separators-from-periods-to-commas/ If comma is considered the decimal separator and period is considered the thousands separator, then 1,00E+02 and 1.00000e-03 are actually equal. 1,00E+02 = 100 1.00000e-03 = 100
  13. How are you terminating the remote session? You should have the option to log off or disconnect. What happens when you simply close the remote desktop application instead of logging off?
  14. Check this: http://stackoverflow.com/questions/13805187/how-to-set-a-variable-inside-a-loop-for-f SETLOCAL ENABLEDELAYEDEXPANSION @echo on :start cd %~dp0 for /f "tokens=*" %%G in (file.txt) do ( set in=%%G set in=!in: =! echo !in! ) pause
  15. You're never setting line equal to "p o t a t o". You're just printing "line=p o t a t o".
×