473,419 Members | 4,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

how to run it on live server to make, a live webserver to a particular port

If I have a WebServer.java file, then after compile to WebServer.class, and upload to server, how to run it on live server to make, a live webserver to a particular port? run localhost success... I must do a JSP and run it from it? how?
Aug 19 '10 #1
9 2597
Dheeraj Joshi
1,123 Expert 1GB
You can use scriplet tag in JSP to run your java code.

Regards
Dheeraj Joshi
Aug 19 '10 #2
My networking textbook says(4th/e kurose/ross)
prog assignment
In the first stage, you will write a multi-threaded server that simply displays the contents of the HTTP request message that it receives. After this program is running properly, you will add the code required to generate an appropriate response.
.................
After your program successfully compiles, run it with an available port number(?), and try contacting it from a browser.To do this, you should enter into the browser's address text box the IP address of your running server. For example, if your machine name is host.someschool.edu, and you ran the server with port number 6789, then you would specify the following URL:

http://host.someschool.edu:6789/

As SAID : In the first stage, you will write a multi-threaded server that simply displays the contents of the HTTP request message that it receives.
I RUN IT localhost and when a request FROM BROWSER
http://localhost:6789/new2.html
appeared in CLI(SERVER) the header, how to this remotely/live server as textbook refers? where view server output stage-1 of assignment localhost=appear in CLI??
Aug 20 '10 #3
In a multithreated webServer, each file in the requested.html (main.html, gifs.gif,jpegs.jpeg) are each a separate threat?
Aug 20 '10 #4
chaarmann
785 Expert 512MB
Read about java socket programming.
Then write the code to listen on (and write to) given port.
Make sure the port isn't blocked by your firewall!

First, develop the single-tread application. Later on, transform it to a much more complicated multithread-application!
Aug 23 '10 #5
Yes I did that,

I RUN IT localhost success, and when a request FROM BROWSER for url:
http://localhost:6789/new2.html
done, appeared in CLI(SERVER running) the header, how to: this remotely/live server as textbook refers? where view server output stage-1 of assignment in live server HENCE IN localhost=appear in CLI??
Aug 23 '10 #6
chaarmann
785 Expert 512MB
You asked:
where view server output stage-1 of assignment in live server HENCE IN localhost=appear in CLI??
You can display the output on your webserver in your shell or Windows-command-box (DOS-Box) with the Java command System.out.println("my Answer"). (Is it that what you mean with CLI? CLI could be abbreviation for Command Line Interface. (Greetings from Amiga!) Or do you want to store the output in database? because CLI is also an abbreviation for Call Level Interface, a Standard-API for database).
You said CLI and server, but it's very unlikely that you really mean what you said. Because if you make an inquiry by browser, it makes more sense to show the answer inside the browser on the client machine (and not on the server).
To show the answer, you must send back a response on the openend port which is connected to the browser. You need to send back HTML-text. For example:
Expand|Select|Wrap|Line Numbers
  1. Content-type: text/html
  2.  
  3.   <html>
  4.       <head>
  5.           <title>My Title</title>
  6.       </head>
  7.       <body>
  8.           My answer 
  9.       </body>
  10.   </html>
  11.  
Of course you can read in this text from a file (named for example "answer.html") instead of hardcoding it in your server program.

Please be sure about the meaning of technical Terms before using them and then please make short, understandable English sentences. I had a lot of problems to understand what you mean.

Or just list your source code here, then it also becomes more clear what you mean.
Aug 24 '10 #7
If I solve this, I think I will make it all others:
Expand|Select|Wrap|Line Numbers
  1. class TCPServer {
  2.     public static void main(String argv[]) throws Exception
  3.         {
  4.                String clientSentence;
  5.                ServerSocket welcomeSocket = new ServerSocket(6789);
  6.                while(true) {
  7.                 Socket connectionSocket = welcomeSocket.accept();
  8.  
  9.                 BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream( ) ) );
  10.  
  11.                 clientSentence = inFromClient.readLine();
  12.  
  13.                    System.out.println("RECEIVED FROM CLIENT : " + clientSentence + "\n");
  14.             }
  15.         }
  16. }
  17.  
insert in browser http://localhost:6789/new.html
appear in Command Line(in live server where appear?):
Expand|Select|Wrap|Line Numbers
  1. C:\Users\User\Documents\TextBooksDataFiles\RexPractice\JAVA\ZIPs\jhtp7_SSM_ch24solutions\te
  2. st\WebServer\aw\P11-ch2>java TCPServer
  3. RECEIVED FROM CLIENT : GET /new.html HTTP/1.1
how run server class file in live server and see results?
Aug 24 '10 #8
chaarmann
785 Expert 512MB
you asked:
how run server class file in live server and see results?
Why do you ask? You have already done exactly that.
You run your server class file in live server with command "java TCPServer". And you have seen the result. The result, as you have listed it, was "GET /new.html HTTP/1.1".
So what's your problem? I can only guess. Maybe you want to show the result in browser? Then just extend your code instead of just putting out the filename "new.html" with println(): read the text from new.html and send it as answer over the current socket back to the browser! (see also previous reply).
That means first you have to parse the result (which is stored in variable "clientSentence") and grab the file name (in this case "new.html"). Then you open this file from disk and read in all its text which you store into a string. Then you send this string back over the socket.
Aug 24 '10 #9
please note by saying live I mean REMOTE SERVER not localhost...well?
Aug 24 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Dave Smithz | last post by:
Hi There, I have taken over someone else's PHP code and am quite new to PHP. I made some changes and have implemented them to a live environment fine so far. However, I now want to setup a...
2
by: Bozo | last post by:
Hi, Does anyone know how to run a .Net exe using a particualr port number to connect to a web service? How do you do this programmatically. Thanks
3
by: ChrisAndTammyHallum | last post by:
I have a VB.NET web project that I wrote on my computer with Studio. It works great, on my computer. However when I ported it over to my company's production server it doesn't know how to handle...
2
by: Stephen Brown | last post by:
We've been using dotNet for a couple of years now and have been updating our live server by just overwriting (Explorer drag and drop) the aspx and assembly files until we had some errors reported...
3
by: Ben Fidge | last post by:
I use the session_end in global.asax to perform clean-up of a temporary shopping cart table. Shoppping Cart items are stored with a session id in the table, and when a session ends a small rountine...
3
by: | last post by:
I'm trying to create a project on a virtual server that runs on port 8000, rather than port 80. I tried creating the project at http://localhost:8000/MyFolder but it keeps telling me that the file...
1
by: enggwaqas | last post by:
I have downloaded a simple port blocker written in vb.net which is working fine, now i want to extend it so that it will display a popup window whenever any application trying to access the...
2
by: niraan | last post by:
Hi guys, am new to rails and now am doing a project in rubyonrails. for development purpose i have use instant rails. Now i need to upload my project to the live server. i have register the domain...
24
TheServant
by: TheServant | last post by:
Hey guys, I used this free tutorial on how to make a live server clock. I did, but a) doesn't work (not too worried, I am sure I can fix this) and b) it out puts the clock to a input text field?! ...
2
by: amskape | last post by:
I created a script where a user can select from a variety of shipping options for an order from within a jQuery dialog box. The shipping rates are delivered via UPS & FedEx. Oddly enough, the ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.