473,320 Members | 1,804 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,320 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 2588
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.