Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

Ayuda para java

Thread view: 
Sergio Alvarez - 21 Jan 2006 00:23 GMT
Hola a todos, espero recibir ayuda... muchas gracias..

Tengo que hacer este problema a partir de un codigo dado, que no se si esta
completo (supngo que no), no si esta correcto (supngo que tampoco)

Pongo el Problema y el codigo, espero que me ayudeis pronto por favor.. lo
necesito urgentemene

--------------------------------

PROBLEMA:

Se trata de construir un Servidor Web muy básico, utilizando sockets TCP de

java. El servidor web estará funcionando siempre, no se desconectará nunca.
El puerto a

utilizar por el servidor web es el 80.

El cliente de nuestro servidor web será un navegador web, no es necesario

implementar ningún cliente.

La interacción entre un navegador web y el servidor web es la siguiente:

. El navegador web se conecta al servidor web.

. El navegador envía su solicitud en una sola línea en la forma:

GET /fichero_solicitado HTTP 1.0

. La solicitud realizada por el navegador web finaliza por un carácter de

retorno de carro ('\r') y un carácter de línea nueva ('\n'), es decir
finalizada

con el fin de línea.

. El servidor web recibe la solicitud, envía el fichero solicitado al
navegador

web y finaliza la conexión.

. El navegador web recibe el fichero enviado por el servidor web, lo muestra
y

finaliza la conexión.

El servidor web utilizará un flujo de texto para enviar ficheros con
extensión

.htm o .html y un flujo binario para el resto de tipos de fichero. El envío
de un fichero

por el flujo de texto se puede hacer carácter a carácter, por bloques de
caracteres o por

líneas. El envío de un fichero por el flujo binario se puede hacer byte a
byte o por

bloques de bytes.

NECESITO:

El Código fuente del servidor web.

-------------------------------------

El codigo del cual partir, es:

GET /index.html 80 HTTP 1.0

Server Socket sescucha = new ServerSocket(Puerto);

while true{
Socket speticion = sescucha.accept();
BufferedReader Entrada_texto =
 new BufferedReader(
 new InputsStreamReader(
 new DataInputStream(speticion.getInputStream() )))
String peticion = Entrada_texto.readline();
System.out.println("recibido"+peticion);
import java.util.*
String Tokenizer Tokens = new StringToKenizer(peticion);
String nomfich = Tokens.nextTocken();
nomfich = Tockens.nextTocken();
nomfich = nomfich.substrings(1);

if(nomfich ends with (".html")){
 char[]buffer = new char [1024];
 File Reader fich = new FileReader(nomfich);
 int leidos=0;
 while (leidos!=-1){
  leidos = fich.read(buffer);
  if (leidos!=-1)
   salidatexto.write(buffer,leidos)
   Printwriter salidatexto = new Printwriter
 }
 salidatexto.flush(); //forzar al buffer a vaciarse
 fich.close();
}
else{
 byte[]buffer = new buffer [1024];
 FileInputStream fich = new FileInputStream(nomfich);
 DataOutputStream salida = new DataOutputSream(speticion .getoutputStream);
 int leidos=0;
 while (leidos!=-1){
  leidos = fich.read(buffer);
  if (leidos!=-1)
   salidatexto.write(buffer,leidos)
   Printwriter salidatexto = new Printwriter
 }
 salidatexto.flush(); //forzar al buffer a vaciarse
 fich.close();
}
hilz - 21 Jan 2006 02:43 GMT
> Hola a todos, espero recibir ayuda... muchas gracias..
>
[quoted text clipped - 3 lines]
> Pongo el Problema y el codigo, espero que me ayudeis pronto por favor.. lo
> necesito urgentemene

oh great...
now we have to solve homeworks and in spanish too!
Luc The Perverse - 21 Jan 2006 03:20 GMT
>> Hola a todos, espero recibir ayuda... muchas gracias..
>>
[quoted text clipped - 6 lines]
> oh great...
> now we have to solve homeworks and in spanish too!

Hop to it!   He "lo necesita"s very "urgente"ly.

--
LTP

:)
Mike Schilling - 22 Jan 2006 06:52 GMT
>> Hola a todos, espero recibir ayuda... muchas gracias..
>>
[quoted text clipped - 6 lines]
> oh great...
> now we have to solve homeworks and in spanish too!

I was helping my son with his Spanish homework last week, which is the only
reason I know what "ayuda" means.
Roedy Green - 21 Jan 2006 04:30 GMT
On Sat, 21 Jan 2006 01:23:52 +0100, "Sergio Alvarez"
<alvarez_sergio@hotmail.com> wrote, quoted or indirectly quoted
someone who said :

>PROBLEMA:
>
>Se trata de construir un Servidor Web muy básico, utilizando sockets TCP de

see http://mindprod.com/jgloss/homework.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.