I would like to understand how does multipart/form-data works during file upload scenario's, Does it chunks the data from client to server while transferring the files ?
I am trying to create a serversocket that send a binary in parts ie send 1024 bytes then wait for acknowledgement from the client before sending the next 1024. I am able to do it in udp but the client is tcp. This is my code so far
import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; public class TestFtp {
[Code]....
I have not been able to send then receive acknowledgement before sending the next 1024 bytes.
I'm new to json and the web. My purpose is to use json data from a server and parse it and show meaningful data to the user. I am aware of json parsing, so no sweat there. However, I would like to know how json data is sent to the front end after which it can be parsed.
Usually in my json parsing examples, I have a variable like var data = ]OR I do a getJSON on a data.json file which I have stored in the project folder. However, I want this data to come real time from a servlet. How to go about this?
So, basically my question is, how do I send real time json data from a servlet backend, say some records which I have extracted from the database using jdbc?
I am trying to connect to a local service over UDP - the simulator works fine, but my code does not... The sender is a separate thread and I have tried blocking, non-blocking, connecting, not connection, reading and re-reading the Oracle docs,
I'm using netbeans to develop an application to send and receive data via RS 232 standard. I can send data but I can't read it.what can I do? I have this message in the console: Underlying input stream returned zero bytes. (I must use also threads to have application in real time but I don't understand very well....
I'm creating a web applicaion. for that i want to create a registration page. and this registration details have to be stored in the database.
I'm getting the below error while trying to send the data ...
The requested resource (/cmd/InsertRegtodb) is not available.
Here cmd is project name and InsertRegtodb is servlet name.
Actually the servlet is present is the mentioned address. but it is not connecting to it
There is one more servlet in the same folder and which is accessible from another jsp. But this servlet is not accessible even though i have used same code as it is used for the servlet which worked for me previously...
I am familiar with Servlet/jsp's and developed a web application using them. Now I am looking in Websocket of Java 7. Documentation is not clear how to integrate the two.
1. Let us say in my listener, I have already determined database connections, log file for log4j etc.. Can I use it in Websocket Java classes based on annotation API of web socket. What is not clear to me how I will access Context parameters for webapp saved in Listener.
2. I like jsp so I can dynamically modify the html to be shown. If I am using api, how will I do that, I know I can return data from websocket, but all the java logic which jsp provides, how can that be implemented using web socket api.
I'm trying to send a text file over a socket, from client to server, but I doesn't work. I will demonstrate a part of the code that isn't working.
The critical part of the server look like this:
while(true) { try { Socket socket = fileSocket.accept(); out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); in = new BufferedReader(new InputStreamReader(socket.getInputStream())); String s = in.readLine();
And the client like this:
Socket = new Socket(address, number); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(Socket.getOutputStream())); BufferedReader in = new BufferedReader(new InputStreamReader(Socket.getInputStream())); BufferedReader fileIn = new BufferedReader(new FileReader(filename)); String s = fileIn.readLine(); out.write(s);
Now I want the s in the server to hold the same string as s in the client, but the server can't read the stream - nothing happens. I know that readLine() reads until a new line character, but it doesn't word to write and read a single character either.
I wrote a program to transfer a file using tcp connection, where I closed socket since the receiver need to detect the end-of--file. But now I like to extend it to multiple file for which i should not close the socket until all the files are send. I can't find a way for this. So how to resolve it.
import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; public class tree_lock_test{ int total_instances; int thread_instances = 0; int N;
[Code] .....
this is compiled with another Peterson class which has implemeted peterson lock for two threads ...
<%@ page import="javax.print.*"%> <%@ page import="javax.print.attribute.*"%> <%@ page import="java.io.*"%> <%out.println("Printing..."); String filename = "c:/20140505_3_40.txt";//this is the text file i want to send to printer // am using tomcat 8 PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
I'm trying to do a program that send a single file from a client to a default directory of a Server. The program use the datagramSocket and datagramPacket for the transfer via UDP. The client sent the packet of the file correctly and the server start the receiving but every time the Server class crashes after it's receiving 4/5 packet (exactly 8192 byte)
Then i put the code of the 2 class and the 2 output.
OUTPUT CLIENT:
PROGRAM TRANSFER PACKAGES name of file is : Doc1.pdf his dimension: 11408 byte
PROGRAM TRANSFER PACKAGES START NEW CONNECTION Directory: C:prova Server waiting in port: 9876 Waiting Client... Name of file is : Doc1.pdf Dimension : 11408
[Code] ....
In this point the program go in loop and didn't anything. I don't understand how can i resolve it...
iam trying to sum all the integers in a binary file. the integers are 0-9. IAM having trouble exiting the while loop to display the sum. below is what i have so far which is not displaying the sum.
import java.io.*; public class binaryAdd{ public static void main(String []args)throws IOException{ DataOutputStream output= new DataOutputStream(new FileOutputStream("myBinary.dat")); for(int i=0;i<10;i++){
By using FileReader, FileWriter and their constituents, I am creating a file to contain employee information ( name, age, hours, etc. ). The user is to input all of the data on a single line and we were asked to implement StringTokenizer to assign that data to the file. I have never used the StringTokenizer before, but I have a rough idea how it is to function. I used pw.println to test what I have so far, now I would like to let the user build the initial file with the "first employees" of the company, and then view the file, and then go back and append new employee data to that same file. My question is, how can I take the user input as a StringTokenizer and add that to the file?
In the for loop below, I thought I would see if it would work, but it does not. The loop only executes once and does not allow me to enter data.
public class Records { public static void main(String [] args) throws IOException { Scanner input = new Scanner(System.in); FileWriter fw = new FileWriter("dbs3.java"); BufferedWriter bw = new BufferedWriter(fw); PrintWriter pw = new PrintWriter(bw); System.out.println("NEW EMPLOYEE DATA SHEET"); System.out.print("Number of new employees: "); int number = input.nextInt();
I am trying to remove a line based on user input. myFile.txt looks like:
Matt Brian John
However when I enter "Brian" (to remove this line), It is deleted on the temp file (myTempFile.txt), but not renamed back to the original file (myFile).
Everything compiles but doesn't work like it should. What the idea is, is to be able to add class personnel objects and have them saved in a file, so that later on i would be able to see them.
Back to my problem: When i create a new "Personnel" and try to run Write and read, to see if my new "Personnel" is added to the list, it's not there at all... what do i do wrong?
import java.io.*; class Personnel implements Serializable //No other action required by Serializable interface. { private long payrollNum; private String surname; private String firstNames;