I have a js code that finds out the timezone and then I am trying to "send" a value to a java backingbean. This code must be execute during the load of the xhtml page because in the process I use the "localTimeZone" bean.
I need to check in my java class the status of the javascript (whether it's enabled or disabled) and based on that few validations will be performed at server side.
If have to use noscript, then any small example for xhtml. My project works on Spring web flow.
I'm fairly good at Java, but somewhat at a loss when the some of the JavaScript below is mentioned. I've attempted to port the below code, but I'm finding it somewhat difficult.
Parts of JavaScript I'm stuck at porting:
1. I'm stuck on the return statement on the 3rd line.
2. Similarly the lines utilizing "charCodeAt", as I keep getting error "Cannot invoke charCodeAt(int) on the primitive type char"
3. Also on the second to last line, I keep getting the error "Cannot invoke padLZ(int) on the primitive type int".
Link to original javascript
Convert between Latitude/Longitude & OS National Grid Reference points
Original JavaScript
Java Code:
OsGridRef.prototype.toString = function(digits) { digits = (typeof digits == 'undefined') ? 10 : digits; e = this.easting, n = this.northing; if (e==NaN || n==NaN) return '??'; // get the 100km-grid indices var e100k = Math.floor(e/100000), n100k = Math.floor(n/100000);
I am new to FTP java api. I wanted to do a Ftp transfer from one server to another server using java. I have the connection details for both servers. I found a link with some code but when I try to execute it it throws an error "Couldn't initiate transfer. Check that filenames are valid."
I am developing a web application using JSF-2.0 on weblogic 10.3.6. I am using Facelets as VDL. I have 5 different machine. They are different according to their OS and their geographical location. On my first xhtml page server (machine) is decided. Then on next page file upload and rest of processing takes place. My restriction is that SSO configuration can be done on only one machine.
So I am restricted to using xhtml files from only my primary server where SSO configuration is done. But I have to connect to servlets or managed-bean of different machine as requests are machine specific and file needs to be uploaded to those machines for processing. So I cannot use redirectUrl as I need to be only on one machine. Is it possible that xhtml on one server can talk to managed-bean on other server(different machine)?.
I am working on a chess game. I need to construct a game room where all the player are present and room chat is up. Also some tables where games are being played. Now my question is how to create this game room?
To me this room must need to be like static or global (if I am not mistaken) that is up when server starts and players can join this room and should be down when server is done. How can I implement such room that would stay up for infinite time.
The goal is as follows: Write a UDP 'CompressionServer' that will take input from the user until it sees a "magic string" at which time it will create a compressed and uncompressed version of the file in the file system.
So, I need to integrate the following "Zip" code in to my UDP server code (which already creates the uncompressed file)... That is where I am stuck at now. My first few attempts had the Zip code after I write to "fout" but that failed to create a ZIP file.
I guess the main point here is what are the key pieces of the ZIP code that I should include and what would be the best spot to place them in my server code...
Zip Code:
import java.io.*; import java.util.zip.*;
public class Zip { static final int BUFFER = 2048; public static void main (String argv[]) { try { String fileInput = argv[0]; String fileOutput = argv[1];
How can I connect to an SSH server in Java? I don't need/want a shell. I just want to connect to the SSH server and get the content of, say, file.txt. How can I do that? Example : I get host, user,pass in txt and connect it with java code!
I'm working on an assignment right now which involves passing a variable series of numbers to the Server to be sorted into the correct order and returned to the client.
So far I have it connecting to the server and asking for my numbers, and I am entering each number and pressing return, and it is accepting each number individually.
One (smaller I think) problem i'm having is with the client code, specifically the while loop.. I've tried to code it so that when I enter a full stop ('.') the program will stop asking me for more numbers and move on to sending them to the server.. but instead it just crashes giving an error.. heres an example
"Enter a number: 1 Enter a number: 3 Enter a number: 2 Enter a number: 1. java.lang.NumberFormatException: For input string: "1." at java.lang.NumberFormatException.forInputString(Num berFormatException.java:65)
[Code] ....
Here's the client code in full
package numberSortprogram; import java.io.*; import java.net.ServerSocket; public class NumSortClient { public static void main(String[] args) { InputStreamReader is = new InputStreamReader(System.in); [Code] ....
The big problem that I have is figuring out how to send the sorted array back to the client..
So, what im trying to get to happen is-
-Client is asked to enter numbers -Client enters series of numbers into an array -Array is converted to a string and sent to the server -String is then split into an array of strings and sorted using compareTo (don't know if this is the best way?) -Sorted array is sent back to client and displayed.
fyi this is making use of streamsockets..
All of the rest of my code is below:
package numberSortprogram; import java.io.IOException; import java.net.*; import java.util.regex.PatternSyntaxException; public class NumSortServer { public static void main(String[] args) { int serverPort = 4444; // default port if (args.length == 1 )
com.microsoft.sqlserver.jdbc.SQLServerException: The connection to the host localhost, named instance sqlexpress has failed. Error: "java.net.SocketTimeoutException: Receive timed out". Verify the server and instance names, check that no firewall is blocking UDP traffic to port 1434, and for SQL Server 2005 or later verify that the SQL Server Browser Service is running on the host. at com.microsoft.sqlserver.jdbc.SQLServerException.ma keFromDriverError(SQLServerException.java:171) at com.microsoft.sqlserver.jdbc.SQLServerConnection.g etInstancePort(SQLServerConnection.java:3174) at com.microsoft.sqlserver.jdbc.SQLServerConnection.p rimaryPermissionCheck(SQLServerConnection.java:937 ) at com.microsoft.sqlserver.jdbc.SQLServerConnection.l ogin(SQLServerConnection.java:800) at com.microsoft.sqlserver.jdbc.SQLServerConnection.c onnect(SQLServerConnection.java:700) at com.microsoft.sqlserver.jdbc.SQLServerDriver.conne ct(SQLServerDriver.java:842) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at jdbc.JdbcSQLServerConnection.main(JdbcSQLServerCon nection.java:25)
I keep getting this error when compiling the code . I think its got to do with the Tomcat server not working well with the textpad app...I'm using windows 8.1(for the course I have to use Textpad 4.7.3 & Apache Tomcat 5.5.7 Server) :
C:UsersReignDownloadsIntec - Codecourse technology59850dChapter 12WorkWebStocks.java:20: package javax.servlet does not exist import javax.servlet.*; ^ C:UsersReignDownloadsIntec - Codecourse technology59850dChapter 12WorkWebStocks.java:21: package javax.servlet.http does not exist import javax.servlet.http.*;
[code]....
tom cat is running as a service it shows started in the tom cat app and as a running service in windows services !!!
I am currently writing two java classes (client and server). The client takes an input number form keyboard and sends it to the server. The server then multiplies this number by two and sends it back to the client. The numbers should also be printed to screen along the way, for example if I input the number 3 I should get
"From Client: 3" "From Server: 6"
They should continuously do this unless a negative number is received by the client, say for example the number -3 is sent to the server and it returns -6.
The code I have for the two classes so far is:
import java.io.*; import java.net.*; import java.nio.ByteBuffer; import java.util.Scanner; class Client { public static void main(String args[]) throws Exception { DatagramSocket clientSocket = new DatagramSocket();
[Code] .....
Currently, when I run the program all I get is an output of the number first entered. I am aware it requires a loop but I don't know where and what the condition should be.
Also if I wanted to adapt this so that it would take the integer from client and subtract two at the server and return to client who sends back to server to keep subtracting two unless it reaches a negative number at which point the client will terminate the program - how might I do this.
I do realise there needs to be a while loop in the above code, but I wanted to test it sent the number from client to server and its not doing it. All I get is a print screen of 'enter number' and then the number I enter.
Server : Java Servlet Client : Simple JSP Communication : Server Sent Events every 1 second Here is the problem.
My code needed the server to send updates every one second to the client as stated above. Hence, I added a while loop with a sleep of 1000 milliseconds in the servlet code as shown below. The following strange behavior is observed:
- While the server is sending updates to the client, and the client window closes by mistake, the server does not stop sending updates It continues sending the data. - When the client is re-opened, it sends data much faster (almost double). For example, the server sends 60 seconds worth of updates (60 updates) in just 25-30 seconds. The server sends faster updates not only for this round of updates, but also for any subsequent updates.
This server behavior is much unexpected. Am I writing the server side code wrong? I have looked around a lot and only found while loop method for modifying the server update interval. Is there any other method which I am missing?
I have a server written in java and can display html pages. but when i try to add css to the page the server doesnt use it.(not my code). Do you have to flag the browser to use css or something?
public class SimpleWebServer extends Thread { public static final String VERSION = "SimpleWebServer"; public static final Hashtable MIME_TYPES = new Hashtable(); static { String image = "image/"; MIME_TYPES.put(".gif", image + "gif"); MIME_TYPES.put(".jpg", image + "jpeg");
I have some data in the database and values can be added on demand. so when ever the value added to the database i need to promt that message to all users which are accessing my website, so how can i acheive this....
I'm using this methodology for Java connection between client and server, the server allows the user to stay connected while it is sending messages, but if you stay an average time of 5 minutes without send anything it is disconnected, I need to increase that time to about 30 minutes or disable this disconnection for inactivity.
Settings: Netbeans 8.0 Windows Seven 64 Bits Ultimante
I'm using this methodology for Java connection between client and server, I copied it from the internet, but the server allows the user to stay connected while it is sending messages, but if you stay an average time of 5 minutes without send anything it is disconnected, I need to increase that time to about 30 minutes or disable this disconnection for inactivity.
Settings: Netbeans 8.0 Windows Seven 64 Bits Ultimante
I am trying to deploy an android application that connects to a java server. I am doing an apointments system, so the client asks for an apointments with a specific office/doctor. What i did, was to create a java server, using object for the offices, and via sockets it communicates with the android client.
The problem is that when i tried to use my (very demo still) app on my phone and sent it to some friends for testing, i coulnt find a way to have my server on the internet.
So I changed to (or trying to) servlet. But, how to do a client server application with servlets. All tutorials i have seen are more on website clients, but thats not what i need.
I'm making a website with articles (like a blog). I have a webpage called admin.html where you insert the data of the article (title, post etc).
Admin.html calls to a servlet and this sends the information to a SQL Database and it stores and my index.jsp calls to database and show the articles.
This works perfect, and a non-programmer can insert new articles. The problem is that I need to create an .html file for every article/post and save it into my server online.
For example if I create "CoolArticle", I need the file "CoolArticle.html" and save it in my hosting.
How I can do it? I never have seen examples online, all were local, so I can't continue.
How is session maintained in the application server, internally what happens when the user has logged in ? We create a session and store the user details which will be stored in the session object in the server with a unique sessionID which will be validated when the same user login the system again? But how exactly the session is maintained in the Server internally?