Using HTTP Requests For Sockets Instead Of TCP
Apr 11, 2014
Generally Socket Programming uses HTTP Protocol to send and receive messages in Java. Can we try to exchange HTTP/HTTPS requests instead of TCP?
a Socket constructs a HTTP request to send to another socket from information it has and sends to another one and Server responds with HTTPResponse.
View Replies
ADVERTISEMENT
May 4, 2010
Is there any kind of way to generate HTTP request within a servlet, dispatch it to the server and get back the answer delivered to the servlet? Or are the servlets meant only to respond to passed requests, not generate them?
(I asked a similar question here: [Code] ..... but no luck)
View Replies
View Related
May 5, 2014
The JSP page is opening but the problem is if l click on the ADD or EDIT button l receive the 405 error Iam using MySQL and glassfish server
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
[Code].....
View Replies
View Related
Jun 17, 2014
I did a Servlet and a JSP with a combobox. I called the JSP on one browser and selected value n1 from the combobox. From another computer, I called the (same URL) and selected value n2. I expected the Servlet to handled both requests separately, however when I select value n2 on the 2nd browser, the jsp on the 1st browser that initially had value 1, now changes into value 2 as well.
Why cant the servlet handle requests separately? users actions on different browsers should not interfere with each other..!
View Replies
View Related
Dec 26, 2014
I have just started learning about sockets and such... and i have created a chat program with a server and a client
server:
public class Server {
private static ServerSocket server;
private static Socket connection;
private static PrintWriter pw;
private static BufferedReader br;
private static JTextField textOutput;
[Code] ....
so, everything is working fine . There is only one thing i would like to do now: make it so that i can run the server from my computer and then others can run the client from theirs and we will be able to chat . So I tried:
In the client code on line 56 is says:
connection = new Socket("localhost",7777);
So I changed "localhost",7777 to "myip",7777)
But when i run the server on my computer and run the client on another computer i get this error:
java.net.ConnectException: Connection refused: connect
Why is the connection getting refused? is it for security reasons? so hackers cant connect to me or something? And is there a way to tell your computer to allow that client to connect?
View Replies
View Related
Mar 13, 2014
I am having a problem passing an int value from one class to the other. The gist of the objective of this program is to compute a local sum at each client, and then once the local sums are computed.. to compute the overall sum from all the clients. My problem is that I'm having trouble figuring out how to pass each sum from each individual client in the class multicastSenderReceiver to the readThread class. I keep getting an error.
I feel that I have to be able to pass the sum value from each client generated in multicastSenderReceiver to the other class, because that is the only way I'll accurately be able to sum up all the values..
Java Code:
package multicastsenderreceiver;
import java.net.*;
import java.io.*;
import java.util.*;
//import static multicastsenderreceiver.multicastSenderReceiver.numProcesses;
class multicastSenderReceiver{
[code]....
View Replies
View Related
Feb 25, 2014
I want to write java code which can block unbuffered I/O requests send to CD driver ...
View Replies
View Related
Jun 9, 2014
I've written an HTTPServlet that send an HTTP request to one HttpListener and receive POST requests from an Http Sender.This is the code:
package sspa.huvr.git;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Date;
[code]...
but when is called from the doPost method it seems that the html content is not sent from the processRequest method.
View Replies
View Related
Dec 18, 2014
Is it possible to send a duplicate soup request?Basically, I have a situation where two almost identical requests can get sent but right now the response comes back as one response. I wanted visibility to the two responses and the one gets dropped off
View Replies
View Related
Dec 6, 2014
I have all of my code written, but it is not producing any output and i'm not sure why.
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
[code]...
View Replies
View Related
Jun 12, 2014
I had to change context path name of my web application due to some organizational shuffle. I have successfully changed it and it has been working fine.
But what is happening is we have used old context path name in reminder and notification emails. so When users hit links from old emails, they are getting 404 Error.
Is there any way to redirect the old request which has old context path to new one?
View Replies
View Related
May 3, 2014
How does jsp create session when there're two requests coming simultaneously from the same client browser(maybe one tab maybe two tabs)?
I ask this question because it is said jsp could solve DuplicateSessionException in flex.
[URL] ....
if so, jsp would create same session(with same session id) for the two requests coming simultaneously?
View Replies
View Related
Aug 13, 2014
Using Java 7 update 5 (I know it's old...), we are trying to send concurrent requests to a RMI Server. When we start to tamp up the load (not too much - up to 50 concurrent requests) we start to see many IO Problems like Broken Pipe and Connection Reset By Peer. Could we be hitting some unknown limitation on concurrent access? Is there such limitation?
View Replies
View Related
Aug 16, 2012
I created an instant messenger using java. When I have the Server that communicates between the clients and one client running on my Computer the CPU Usage is at 100%. It really slows down everything else I'm doing and I figure this might be an issue if I gave this to people to use. I don't want the client taking up a lot of CPU Usage if they're just running it in the background while doing other things on their computer. The program utilizes multithreading. Each thread is constantly being polled for input.
The Server, as seen below, has two threads. I explain what the threads do before the code. There is also another while loop running constantly in the server that is waiting for sockets to connect. The loop does not run constantly at the line socket.accept(); it stops and just waits.
The User, split into a menu and chat window, has two threads as well. I explain what the threads do before the code. After I originally posted I put a 100 ms sleep in all my threads. CPU Usage is still at 100%*
This thread listens for input from the user. The input tells the server what action to take. There is a thread running for every user currently connected to the server.
public void run()
{
try
{
input = new DataInputStream(user.getSocket().getInputStream());
output = new DataOutputStream(user.getSocket().getOutputStream());
[code]....
View Replies
View Related
Apr 8, 2014
I have written a java code to transfer files from one server to another using the concept of socket programming. I got the codes from another java forum that meet my requirements. The program is said to transfer large sized files (like .mkv , .mprg movies) from one machine to another and can be used to transfer files of all formats. But after running the codes I found that the program is not able to transfer large sized files such as movies and even pdf of sizes 80mb or 111mb. When i transfer small sized files, it gets transferred and the output shows that. You can run the codes and observe it. But when i try to transfer large sized files, the program goes on running for hours. The large sized files are not getting transferred. The program has used bytebuffer but still this error occurs.
**ClientMain.java**
import java.io.IOException;
import java.net.Socket;
public class ClientMain
[code]....
Note that:-
1. ClientMain.java and DirectoryTxr.java are the two classes under client application.
2. ServerMain.java and DirectoryRcr.java are the two classes under Server application.
3. run the ClientMain.java and ServerMain.java simultaneously
Also specify the source directory, destination directory and host address of the machine in which server is running in the ClientMain.java(as per your computer). Here we are not specifying source file ,instead a source directory or folder is specifying.So the entire files of source directory will be transferred.
View Replies
View Related
Dec 26, 2014
I have been practicing writing java code, my university course is going to cover socket programming and multi-threading.
I am presently just starting to write myself a framework for all multiplayer games I may make in the future, my aim really is simply to practice and understand better and this time, im not using an ide, just sublime text, all new grounds for me, I have a good basic understanding of the subject but I want to be fluent.
import java.net.*;
import java.util.ArrayList;
import java.io.*;
/*SMOOTH THREAD SAFE MULTI CLIENT HANDLING CLASS.
*
*This class will create connection objects when a connection is detected, these connections will run in a separate thread and update an array list in their parent class containing their last sent data
[Code] .....
View Replies
View Related
May 7, 2014
This question has confused me because "Errors" are capitalized and I'm not sure what they mean.
To me this question is false. Sockets can be used to transfers file over a network.
I can't see why this wouldn't work. The code looks fine to me.
I don't think this is true unless you're using the mouseEntered() or mouseExited() method. But again, I'm not sure.
I think this is true, I don't know what else could have listeners.
They're only worth a few marks each so the answer is only suppose to be a line or two. They are all true or false questions that require an explanation.
View Replies
View Related
Apr 3, 2014
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 )
[Code] .....
View Replies
View Related
Oct 6, 2014
I have an application written in Java on the Linux platform. My application will work the following way:
User A will open application. User B will open application.User A will need to send User B a message but without a socket connection.User B will need to send User A a message but without a socket connection.The user should be able to identify the messages sent to each other.If User A reads user B's message the message will no longer be available in the channel of communication.If one user exits their application their message should be removed.User C should not be able to read user A and user B message (This is only via the application design, no real security here).Applications should be able to work on different machines however they will utilize a shared network mount to access files modified by each other.
I do have to note that the messages being sent is rather small and only 1 message is sent from each user, so in that regard I did not want to setup a client/server model to do this using sockets.
Basically I am looking for a similar concept as a message queue but more relevant to my requirements done in Java. What are some good options to use that will address some of my requirements? I have not touched Java in a long time and only have used it for certain usage so I am trying to get an idea of which current technologies are best for what I need.
View Replies
View Related
Jan 31, 2015
I have written the following code to handle multiple Client Request. Lets Assume that it takes server 300 nano seconds(ns) to process one connection request. It recieves two connection requests at time t1 and t1+200ns. Since server is busy handling request 1 at time t1+200ns. what will happen to request 2.if yes what is the max size of that buffer?Maximum number of request that a server process per unit time depends on the java code.Is there also a limit to how many request a server can recieve per unit time?
public class EchoServer
{
public static void main(String args[])
{
ServerSocket serverSocket = null;
BufferedReader readSocket = null;
PrintStream writeSocket = null;
serverSocket = new ServerSocket(9998);
[code]...
View Replies
View Related
May 26, 2014
I am working on a project with client/server relationship and I want the client to be able to transfer their personal music files over the socket. Every time I attempt to do it the file is created but it is empty.
Server code:
Java Code:
public class Server extends JFrame {
//===============================
// FIELDS
//===============================
// connection essentials
private ServerSocket server;
private Socket connection;
[Code] ....
View Replies
View Related
Mar 9, 2014
i am using netbeans6.7.1 version i implemented one program i.e web application ..when am excuting this one i got one error http status 500...
this is the code:
SumServlet.java
package com.sum;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
[code]....
View Replies
View Related
May 10, 2014
i have one html page through which i want to go to servlet page but after submit it give the http 404 error.
i am using tomcat apache server.
View Replies
View Related
Oct 13, 2014
my project is all about downloading files(text files, music files, etc) from a LINUX server using UI build in java, my mentor told me to use HTTP Client (Java apache), but how to start this.
Here's a sample scenario:
ScreenHunter_1.jpg
Consider the directory structure above.
First, how to connect with this LINUX server using JAVA.
ScreenHunter_2.jpg
and how to dowload the above file.
View Replies
View Related
Mar 9, 2014
correct this error
WishSrv.java
package com.wish;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Calendar;
import javax.servlet.ServletException;
[code]...
View Replies
View Related
Jul 6, 2014
I am trying to write to an http server, but nothing happens. I can read from the file, I just cannot write to it and no errors are thrown. I do not know how to proceed.
Specifically, I have a text file on my server, and I can read from it (the text file already has content), but I cannot write to it. And, no exceptions are thrown.
url = new URL("http://kajl-ig.com/txt.txt");
urlConn = url.openConnection();
urlConn.setDoInput(true);
urlConn.setDoOutput(true);
urlConn.setUseCaches(false);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(urlConn.getOutputStream()));
String s = "TEST Successfull!";
[code].....
The second code, I got from some random website, and I was desperate so I tried it. I am not sure what the
urlConn.setRequestProperty (String, String);
method does, so I removed it and it reads fine it just cannot write.
View Replies
View Related