Red de conocimiento informático - Descarga de software - Utilice JAVA para crear una página web (página de registro).

Utilice JAVA para crear una página web (página de registro).

& lt%@page content type = " text/html; charset = GB 2312 " language = " Java " import = " Java . SQL . * " página de error = " " " & gt;

& lt ! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transicional//ES " " http://www . w3 . org/TR/XHTML 1/DTD/XHTML 1-Transicional . DTD " & gt; >& lthtml xmlns = " http://www . w3 . org/1999/XHTML " & gt;

& lthead & gt

& ltmeta http-equiv = " Contenido- Escriba " Content = " text/html; charset=gb2312" />

& lttitle & gtRegistro de nuevo usuario

& ltscript language = " JavaScript " src = " js /send _ request . js " >& lt/script & gt;

& Lenguaje de script = " javascript " & gt

Función actualizarImagen(){

document.getElementById( "imagen "). src = "image.jsp

}

Función checkInput(){

var f = documento. formularios[ 0];

var nombreusuariopatrn = /^[a-za-z]{4,12}$/;

If (! nombre de usuario patrón . exec(f . nombre de usuario . valor ))

Alert("El nombre de usuario ingresado es ilegal, ¡vuelva a ingresar!");

f .Username.Select;

f .Username .focus();

Devuelve falso

}

var contraseñapartrn = /^(\w){6,12}$/;

Si (! contraseñapartrn . exec(f . contraseña . valor)){

Alerta("La contraseña no cumple con los requisitos, ¡vuelva a ingresarla! ");

f . passowrd . focus();

Devuelve falso

}

if(f.contraseña.valor! = f.passwordverify.value){

Alert("Las dos contraseñas ingresadas son diferentes, ¡vuelve a ingresar!");

f focus(); p>

Devuelve falso

}

Document.getelementbyid("info internalhtml = "Procesando. . . Espere por favor. . .

";

send_request("get "," private/register1.jsp?username="+f.username.value+" & contraseña="+f.password.value+

" & ampcheckCode="+f.check.value, null, " text ", devolución de llamada);

}

Devolución de llamada de función(){

if(http_request . estado listo == 4){

if(http_request.status == 200){

var resultado = http_request .responsetext;

p>

if( resultado == 1){

Alerta ("¡Registro exitoso! ¡Haga clic en Aceptar para ingresar a la interfaz principal!");

ubicación de la ventana = " página principal . html ";

p>

}

elseAlert(resultado);

}

else{

Alert( "Excepción de página");

alerta(http_request.status);

}

}

}

& lt/script & gt;

& lt/head & gt;

& ltbody & gt

& ltform action = " " nombre = " formulario 1 " método = " publicación " >

& lttable width = " 100% " & gt;

& lttr align="center " >

& lttd align="right " > Nombre de usuario:

& lttd align="left " >& ltinput type = " text " size = " 12 " maxlength = " 12 " id = " nombre de usuario " nombre = " nombre de usuario "/>

(2-12 caracteres, todos deben ser letras en inglés)& ltlabel id = " info " style = " color:# 0033 ff " & gt; & lt/TD & gt ;

& lt /tr & gt;

& lttr & gt

& lttd align="right " >Contraseña:

& lttd align="left " >& ltinput tipo = " contraseña " tamaño = " 12 " maxlength = " 12 " id = " contraseña "/& gt (4-12 caracteres)

& lt /tr & gt;

& lttr & gt

& lttd align="right " >Confirmación de contraseña:

& lttd align="left " >& ltinput type = " contraseña " tamaño = " 12 " maxlength = " 12 " id = " contraseña verificar "/& gt (4-12 caracteres)

& lt/tr & gt;

& lttr & gt

& lttd align="right " >& ltimg src = " imagen . JSP

" id = " image "/& gt;& lt/TD & gt;

& lttd align="left " >& ltInput type="button" value="No puedo ver con claridad, por favor cambiar el código de verificación" onclick = "JavaScript:refresh image();"/& gt;</TD>

</tr>

<tr>

& lttd align="right " >Ingrese el código de verificación:

& lttd align="left " >& ltinput type = " text " size = " 12 " maxlength = " 12 " id = " check " nombre = " comprobar "/& gt;& lt/TD & gt;

& lt/tr & gt;

& lttr & gt

& lttd align="right " >& ltinput type = " botón " valor = " enviar " onclick = " JavaScript:check input();"/& gt;& lt/TD & gt;

& lttd align="left " >& ltinput type = " reset " value = " cancelar "/& gt;& lt/TD & gt;

& lt/tr & gt;

p>

& lt/table & gt;

& lt/form & gt;

& lt/body & gt;

& lt/ html>

Ajax

Esto es image.jsp.

& lt% @ tipo de contenido de página = "imagen/JPEG" import = " Java . awt . *, java .awt.image.*, java.util.*, javax.imageio. * " % & gt

& lt%!

Color getRandColor( Aleatorio aleatorio, int fc, int bc)

{

si(fc & gt; 255)fc = 255;

si(BC & gt; 255 )BC = 255;

int r = fc+random . nextint(BC-fc);

int g = fc+nextint(BC-fc);

int b =. fc+random . nextint(BC-fc);

Devuelve nuevo color (r, g, b);

}

% & gt

& lt%

response.setHeader("Pragma", "Sin caché");

respuesta set header(" Cache- Control "," no-Cache ");

response.setdate header("Expires",0);

//Establece el largo y el ancho de la imagen.

int width=176, height = 30

//Establece caracteres chinos alternativos y elimina algunos caracteres chinos indecentes.

cadena base = " \u 7684 \ u4e 00 \ u4e 86 \ u662f \ u 6211 \ u4e0d \ u 5728 \ u4e ba \ u4eec \ u 6709 \ u 6765 \ u4ed 6 \ u8fd 9 \ u4e0a \ u 7740 \u4e2a \u 5730 \u 5230 \u 5927 "+

" \u 91cc \u8bf 4 \u5c 31 \u53bb \u5b 50 \u5f 97 \u4e5f \u548c \u90a 3 \u 8981 \ u4e0b \ u770b \ u 5929 \ u65f 6 \ u8fc 7 \ u 51fa \ u5c0f \ u4e 48 \ u8d 77 "

" \ u90fd \ u628a \ u597d \ u8fd 8 \ u 591a \ u6ca 1 \ u4e3a \u53c 8 \u53ef \u5bb 6 \u5b 66 \u53ea \u4ee 5 \u4e3b \u4f 1a \u5e 74 \u60f 3 \u751f \u540 c

" \u4ece \u81ea \u9762 \u524d \u5934 \u9053 \u5b 83 \u540e \u7136 \u8d 70 \u5f 88 \u50cf \u89c 1 \u4e 24 \u7528 \u5979 \u56fd \u52 A8 \u8fdb \U6

" \u4f5c \u5bf 9 \ u5f 00 \ u800c \ u5df 1 \ u4e 9 b \ u73b 0 \ u5c 71 \ u6c 11 \ u 5019 \ u7e cf \ u53d 1 \ u5de 5 \ u 541 \ u438

" \ u4e8e \ u9ad 8 \u624b \u77e 5 \u7406 \u773c \u5fd 7 \u70b 9 \u5fc 3 \u6218 \u4e8c \u95ee \u4f 46 \u8e ab \u65b 9 \u5b9e \u5403 \u505a \u53eb \u5f 53 \u4f4f \u54 2c\ u542c

" \u 6253 \u 5462 \u 771f \u 5168 \u624d \u56db \u5df 2 \u 6240 \u654c \u4e4b \u 6700 \u 5149 \u4ea 7 \u60c 5 \u8 def \ u 5206 \ u603b \ u 671 \ u766

" \ u4eb 2 \ u5982 \ u88ab \ u82b 1 \ u53e \ u13f \ u5e 38 \ u6c 14 \ u4e 94 \ u7b2c \ u4f7f \ u 5199 \ u 519b \u 5427 \u 6587 \u8fd 0 \u 565433

" \u5feb \u660e \u884c \u56e 0 \u522b \u98de \u 5916 \u 6811 \u 7269 \u6d3b \u90e 8 \u95e 8\u65e 0\u5f

80 \u 8239 \u 671b \u65b 0 \u5e 26 \u98

" \u7ad 9 \u4ee 3 \u5458 \u673a \u66f 4 \u4e5d \u60a 8 \u6bcf \u98ce \u7ea 7 \u8ddf \u7b 1 \u554a \u5b 69 \u4e 07 \u5c 11 \u76f 4 \u610f \u59

" \u 91cd \u4fbf \u 6597 \u9a6c \u54ea \u 5316 \u592a \u 6307 \ u53d 8 \ u793e \ u4f3c \ u58eb \ u 8005 \ u5e 72 \ u77f 3 \ u6ee 1 \ u65e 5 \ u 51 B3 \ u767e \ u

" \ u 5404 \ u 516d \ u672c \ u 601d \ u89e 3 \ u7acb \ u6cb 3 \ u 6751 \ u 516b \ u96be \ u65e 9 \ u8bba \ u 5417 \ u 6839 \ u 51765438 \ u

" \ u5e 94 \ u 5173 \ u4fe 1 \ u89c 9 \u6b 65 \u53cd \u 5904 \u8bb 0 \u5c 06 \u 5343 \u627e \u4e 89 \u 9886 \u 6216 \u5e 08 \u7ed 3 \u 5757 \u8dd 1 \u88

" \u 811a \u7d 27 \u 7231 \u7b 49 \u4e 60 \u 9635 \u 6015 \u 6708 \u 9752 \u534 a \u706b \u6cd 5 \u 9898 \u5efa \u8d 76 \u4f4d \u 5531 \u 6438

" \u 611f \u 51c 6 \u5f 20 \u56e 2 \u5c4b \u79bb \u 8272 \u 8138 \u 79d 1 \u 5012 \u775b \u 5229 \u4e 16 \ u 5265433

" \ u 591f \ u 6574 \ u8ba 4 \ u54cd \ u96ea \ u6d 41 \ u672a \ u573a \ u8be 5 \ u5e 76 \ u5e 95 \ u6df 1 \ u523b \ u5e 73 \ u4f 1f \u5fd 9 \u63d 0 \u786e \u8fd 65438+

" \u519c \u53e 4 \u9ed 1 \u544a \u754c \u62c 9 \u540d \u5440 \u571f \u6e 05 \u 9633 \u 7167 \u529e \u53f 2 \u 6539 \u 5386 \u8f6c \u753b \u 9020

" \u5fc 5 \u670d \u96e 8 \u7a7f \u 5185 \u8bc 6 \u9a8c \u4f 20 \u4e 1a \u83dc\u722c\u 7761\u 5174\u5f 62\u 91cf\

u54b 1 \ u89c 2 \ u89c 2

" \ u 7834 \ u53cb \ u5ea 6 \ u672f \ u996d \ u516c \ u65c 1 \ u623f \ u 6781 \ u5357 \ u67aa \ u8bfb \ u6c 99 \ u5c 81 \u7ebf \u91ce \u575a \u7a 7 a \u7a

" \u653f \u57ce \u52b 3 \u843d \u94b 1 \u7279 \u56f 4 \u5f 1f \u80dc \u 6559 \u70ed \ u5c 55 \u 5305 \u6b4c \u7c7b \u6e 10 \u5f3a \u 6570 \u4e 1 \u

" \u54e 5 \u9645 \u65e 7 \u795e \u5ea 7 \u7ae 0 \u5e2e \u 5566 \ u53d 7 \u7cfb \u4ee 4 \u8df 3 \u975e \u4f 55 \u725b \u53d 6 \u 5165 \u5cb 8 \u 6562 \u 6389 \u5ffd \u79cd \u888

" \u 9876 \ u 6025 \u 6797 \u505c \u606f \u53e 5 \u533a \u 8863 \u822c \u62a 5 \u53f 6 \u538b \u 6162 \u53d 4 \u80cc \u7ec 6 ";

/ /El longitud de caracteres chinos alternativos

int length = base.length()

//Crear una imagen de memoria

Imagen BufferedImage = new BufferedImage(ancho, Alto) , BufferedImage. TYPE_INT_RGB);

//Obtener contexto de gráficos

gráficos g = imagen. obtener gráficos();

//Crear ejemplo de clase aleatoria

Random Random = new Random();

//Establece el color de fondo de la imagen (debido a que se usa como fondo, el color debe ser más claro)

g.setColor(getRandColor(aleatorio, 200, 250));

g.fillRect(0, 0, ancho, alto);

//Fuente alternativa

cadena[]tipos de fuente = { "\u5b8b\u4f 53", "\u65b0\u5b8b\u4f53", "\u9ed1\u4f53", "\u6977\u4f53", "\u96b 6\u4e 66 " };

int longitud de tipos de fuente = longitud de tipos de fuente;

//Agrega ruido al fondo de la imagen.

g.setColor(getRandColor(aleatorio, 160, 200));

g.setFont(nueva fuente("Times New Roman", fuente.

simple, 14));

for(int I = 0;i<6;i++)

{

g drawstring(" * * * * * * . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ", 0, 5 *(I+2));

}

//Obtenga el código de autenticación generado aleatoriamente (6 caracteres chinos)

//Guarde la cadena china generada.

String sRand =

for(int I = 0;i<4;i++)

{

int start = nextint(. length);

string rand = base. substring(start, start+1);

sRand+= rand;

//Establecer el color de fuente.

g.setColor(getRandColor(random, 10, 150));

//Establecer fuente

g.setFont(new font(Tipos de fuente[random] . nextint(fontTypesLength)], Font. BOLD, 18+random . nextint(6)));

//Dibuja este carácter chino en la imagen.

g.drawString(rand, 24*i+ 10 + random.nextInt(8), 24

}

session.setAttribute("rand "); , sRand);

g. dispose();

ImageIO.write(imagen, "JPEG", respuesta. obtener flujo de salida());

%>