Jaja suele pasar no te preocupes. No sé si podrías poner el código completo por si le sirve a alguien más en el futuro.
Un saludo.
Un saludo.
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8"/>
<title>Identfíquese</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"/>
<link rel="stylesheet" href="assets/css/login.css"/>
</head>
<body>
<div id="flogin" class="flogin">
<section class="left-side">
<section class="head">
LOGIN
</section>
<section class="body">
<section class="data">
<section class="form-group">
<span>Usuario:</span>
<section class="input-wrapper">
<input type="text" id="txt-username" class="txt"/>
<i class="fa fa-user"></i>
</section>
</section>
<section class="form-group">
<span>Contraseña:</span>
<section class="input-wrapper">
<input type="password" id="txt-password" class="txt"/>
<i class="fa fa-key"></i>
</section>
</section>
</section>
<section class="help">
<a href="">¿Olvidaste tu usuario o contraseña?</a>
</section>
</section>
</section>
<section id="btn-login" class="right-side">
<i class="fa-4x fa fa-arrow-right"></i>
<span>IR</span>
</section>
</div>
</body>
</html>
.flogin {
display: flex;
justify-content: space-between;
width: 400px;
}
.flogin > .left-side {
background-color: #363636;
/*background: radial-gradient(#555, #363636, #363636);*/
box-shadow: 0px 0px 20px 20px #2e2e2e inset;
border: 9px solid #dedede;
border-right: none;
border-radius: 20px 0px 0px 20px;
width: 80%;
}
.flogin > .right-side {
align-items: center;
background-color: #34B5D5;
border: 9px solid #dedede;
border-left: none;
border-radius: 0px 20px 20px 0px;
display: flex;
flex-flow: column nowrap;
justify-content: space-between;
padding: 1.3rem .2rem;
width: calc(20% - 2*.2rem - 9px);
}
.flogin > .right-side:hover {
cursor: pointer;
}
/*********************
LEFT SIDE
*********************/
.left-side > .head {
border-bottom: 2px dashed #ddd;
color: #eee;
font-family: "segoe ui";
margin-bottom: 20px;
padding: .75rem 1rem;
}
.left-side > .body {
padding: .8rem 1.35rem;
width: calc(100% * 2*1.35rem);
}
.body > .data {
display: flex;
justify-content: space-between;
}
.form-group {
width: 45%;
}
.form-group > span {
color: #ddd;
display: block;
font-family: "segoe ui";
font-size: 10pt;
margin-bottom: 7px;
}
.form-group > .input-wrapper {
align-items: center;
background-color: white;
border-radius: 5px;
box-shadow: 0px 2px 5px 1px rgba(0,0,0,.4) inset,
0px -1px 2px 1px rgba(0,0,0,.25) inset;
display: flex;
justify-content: space-between;
}
.input-wrapper > .txt {
width: 80%;
}
.input-wrapper > i {
color: gold;
width: 20%;
}
.txt {
background-color: transparent;
border: none;
border-radius: 5px;
padding: .4rem .25rem;
width: calc(80% - 2*.35rem - 2*1px);
}
.txt:focus {
outline: none;
}
.help {
display: flex;
justify-content: flex-end;
}
a {
color: #ddd;
display: block;
font-family: "segoe ui";
font-size: 10pt;
font-style: italic;
margin-top: 20px;
text-align: right;
text-decoration: none;
}
/*****************
RIGHT SIDE
*****************/
.right-side > i {
color: #fff;
display: block;
}
.right-side > span {
color: #fff;
display: block;
font-family: "segoe ui";
font-size: 16pt;
}
CitarOk it works! Using the same FileInputStream of the first 256... A newbie error! thx! Maybe there are a better thing for do that?
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Identfíquese</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/css/login.css"/>
</head>
<body>
<div id="flogin" class="flogin">
<section class="left-side">
<section class="head">
LOGIN
</section>
<section class="body">
<section class="data">
<section class="form-group">
<span>Usuario:</span>
<section class="input-wrapper">
<input type="text" id="txt-username" class="txt"/>
<i class="fa fa-user"></i>
</section>
</section>
<section class="form-group">
<span>Contraseña:</span>
<section class="input-wrapper">
<input type="password" id="txt-password" class="txt"/>
<i class="fa fa-key"></i>
</section>
</section>
</section>
<section class="help">
<a href="">¿Olvidaste tu usuario o contraseña?</a>
</section>
</section>
</section>
<section id="btn-login" class="right-side">
<i class="fa-4x fa fa-arrow-right"></i>
<span>IR</span>
</section>
</div>
<!-- javascript files -->
<script src="assets/js/login.js"></script>
</body>
</html>
* {
margin: 0px;
padding: 0px;
}
body {
align-items: center;
background-color: #f9f9f9;
display: flex;
height: 100vh;
justify-content: center;
}
.flogin {
display: flex;
justify-content: space-between;
width: 400px;
}
.flogin > .left-side {
background-color: #363636;
border: 9px solid #dedede;
border-right: none;
border-radius: 20px 0px 0px 20px;
width: 80%;
}
.flogin > .right-side {
align-items: center;
background-color: #34B5D5;
border: 9px solid #dedede;
border-left: none;
border-radius: 0px 20px 20px 0px;
display: flex;
flex-flow: column nowrap;
justify-content: space-between;
padding: 1.3rem .2rem;
width: calc(20% - 2*.2rem - 9px);
}
.flogin > .right-side:hover {
cursor: pointer;
}
/*********************
LEFT SIDE
*********************/
.left-side > .head {
border-bottom: 2px dashed #ddd;
color: #eee;
font-family: "segoe ui";
margin-bottom: 20px;
padding: .75rem 1rem;
}
.left-side > .body {
padding: .8rem 1.35rem;
width: calc(100% * 2*1.35rem);
}
.body > .data {
display: flex;
justify-content: space-between;
}
.form-group {
width: 45%;
}
.form-group > span {
color: #ddd;
display: block;
font-family: "segoe ui";
font-size: 10pt;
margin-bottom: 7px;
}
.form-group > .input-wrapper {
align-items: center;
background-color: white;
border-radius: 5px;
box-shadow: 0px 2px 5px 1px rgba(0,0,0,.4) inset,
0px -1px 2px 1px rgba(0,0,0,.25) inset;
display: flex;
justify-content: space-between;
}
.input-wrapper > .txt {
width: 80%;
}
.input-wrapper > i {
color: gold;
width: 20%;
}
.txt {
background-color: transparent;
border: none;
border-radius: 5px;
padding: .4rem .25rem;
width: calc(80% - 2*.35rem - 2*1px);
}
.txt:focus {
outline: none;
}
.help {
display: flex;
justify-content: flex-end;
}
a {
color: #ddd;
display: block;
font-family: "segoe ui";
font-size: 10pt;
font-style: italic;
margin-top: 20px;
text-align: right;
text-decoration: none;
}
/*****************
RIGHT SIDE
*****************/
.right-side > i {
color: #fff;
display: block;
}
.right-side > span {
color: #fff;
display: block;
font-family: "segoe ui";
font-size: 16pt;
}
document.addEventListener("DOMContentLoaded", init, true);
function init() {
document.querySelector("#btn-login").addEventListener("click", handleLogin, true);
function handleLogin(e) {
e.preventDefault();
var txtUsername = document.querySelector("#txt-username");
var txtPassword = document.querySelector("#txt-password");
var userdata = '{"username":'+txtUsername.value+',"password":'+txtPassword.value+'}';
loginByAjax(userdata);
resetForm();
}
function loginByAjax(data) {
var request = new XMLHttpRequest();
request.open("POST", "LoginController", true);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.onreadystatechange = function() {
// si la respuesta fue exitosa
if(request.readyState == 4 && request.status == 200) {
var message = request.responseText;
alert(message);
}
// si la respuesta trajo error
else if(request.readyState == 4 && request.status != 200){
var message = request.responseText;
message = request.responseText;
alert(message);
}
};
request.send("userdata="+data);
}
function resetForm(form) {
var form = document.querySelector("#flogin");
var controls = form.querySelectorAll("input, select");
for(var i=0; i<controls.length; i++) {
var control = controls[i];
if(control.nodeName === "INPUT")
control.value = "";
else if(control.nodeName === "SELECT")
control.selectedIndex = 0;
}
controls[0].focus();
}
}
function loginByAjax(data) {
var request = new XMLHttpRequest();
request.open("POST", "LoginController", true);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.onreadystatechange = function() {
// si la respuesta fue exitosa
if(request.readyState == 4 && request.status == 200) {
var message = request.responseText;
alert(message);
}
// si la respuesta trajo error
else if(request.readyState == 4 && request.status != 200){
var message = request.responseText;
message = request.responseText;
alert(message);
}
};
request.send("userdata="+data);
}
request.send("userdata="+data);
if(request.readyState == 4 && request.status == 200) {
var message = request.responseText;
alert(message);
}
if(request.readyState == 4 && request.status == 200)
package com.company.controllers;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
@WebServlet(asyncSupported=true, urlPatterns={"/LoginController"})
public class LoginController extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final Logger logger = Logger.getLogger("LoginLogger");
public LoginController() {
super();
}
public void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter writer = response.getWriter();
response.setContentType("text/plain");
String strJson = request.getParameter("userdata"); // obtiene lo enviado por AJAX
JSONObject json = new JSONObject(strJson);
String username = (String) json.get("username");
String password = (String) json.get("password");
if(username.equals("Duke") && password.equals("Duke777")) {
writer.print("Usuario correctamente identificado");
} else {
writer.print("Usuario o contraseña incorrectas");
}
writer.flush();
writer.close();
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
processRequest(request, response);
} catch(ServletException | IOException e) {
logger.warning(e.getLocalizedMessage());
}
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
processRequest(request, response);
} catch(ServletException | IOException e) {
logger.warning(e.getLocalizedMessage());
}
}
}
String strJson = request.getParameter("userdata"); // obtiene lo enviado por AJAX
JSONObject json = new JSONObject(strJson);
var userdata = '{"username":'+txtUsername.value+',"password":'+txtPassword.value+'}';
JSONObject json = new JSONObject(strJson);
String username = (String) json.get("username");
String password = (String) json.get("password");
if(request.readyState == 4 && request.status == 200) {
var message = request.responseText;
alert(message);
}
// si la respuesta trajo error
else if(request.readyState == 4 && request.status != 200){
var message = request.responseText;
message = request.responseText;
alert(message);
}
CitarC://program Files/
CitarC://program Files/glassfish/
import java.util.List;
import java.util.ArrayList;
public class Session {
private Byte id;
private List<String> schedules;
private SessionSeats sessionSeats;
public Session() {
schedules = new ArrayList<>();
}
public Session(Byte id, List<String> schedules., SessionSeat sessionSeats) {
this.id = id;
this.schedules = schedules;
this.sessionSeats = sessionSeats;
}
public Byte getid() {
return id;
}
public void setid(Byte id) {
this.id = id;
}
public List<String> getSchedules() {
return schedules;
}
public void setSchedules(List<String> schedules) {
this.schedules = schedules;
}
public SessionSeats getSessionSeats() {
return sessionSeats;
}
public void setSessionSeats(SessionSeats sessionSeats) {
this.sessionSeats;
}
public void addSchedule(String schedule) {
schedules.add(schedule);
}
public String removeSchedule(String schedule) {
shedules.remove(schedule);
return schedule;
}
}
public class SessionSeats {
private Character[][] seats;
public SessionSeats(Character[][] seats) {
this.seats = seats;
if(seats[0] == null)
fillSeatsByDefault();
}
public Character[][] getSeats() {
return seats;
}
public void showSeats() {
for(short row=0; row<seats.length; row++) {
for(short col=0; col<seats[row].length; col++) {
System.out.println(seats[row][col]);
}
}
}
private void fillSeatsByDefault() {
for(short row=0; row<seats.length; row++) {
for(short col=0; col<seats[row].length; col++) {
seats[row][col] = 'O';
}
}
}
private void reserveSeat(Integer row, Integer column) {
seats[row][column] = 'X';
}
}
import java.util.List;
import java.util.ArrayList;
public class Room {
private Byte id;
private List<Session> sessions;
public Room() {
sessions = new ArrayList<>();
}
public Room(Byte id, List<Session> sessions) {
this.id = id;
this.sessions = sessions;
}
public Byte getid() {
return id;
}
public void setid(Byte id) {
this.id = id;
}
public List<Session> getSessions() {
return sessions;
}
public void setSessions(List<Session> sessions) {
this.sessions = sessions;
}
public void addSession(Session session) {
sessions.add(session);
}
public Session removeSession(Session session) {
sessions.remove(session);
return session;
}
}
public class MovieTheater {
private String name;
private List<Room> rooms;
private final TicketSeller ticketSeller;
public MovieTheater(String name, List<Room> rooms) {
this.name = name;
this.rooms = rooms;
ticketSeller = new TicketSeller(rooms);
}
public Ticket buyTicket() {
ticketSeller.buyTicket();
}
// tus otros metodos aquí...
}
public class Ticket {
private String owner;
private Session sessionId;
private String schedule;
private Integer seat[];
public Ticket() {
seat = new Integer[2];
}
public Ticket(String owner, Session session, String schedule, Integer[] seat) {
this.owner = owner;
this.session = session;
this.schedule = schedule;
this.seat = seat;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public Session getSession() {
return sessionId;
}
public void setSessionId(Session session) {
this.session = session;
}
public String getSchedule() {
return schedule;
}
public void setSchedule(String schedule) {
this.schedule = schedule;
}
public Integer[] getSeat() {
return seat;
}
public void setSeat(Integer[] seat) {
this.seat = seat;
}
}
public class SessionUtils {
private void showSchedules(List<Room> rooms) {
for(Room room : rooms) {
for(Session session : room.getSessions()) {
for(String schedule : session.getSchedules())
System.out.println(schedule);
}
}
}
private Byte getSessionId(List<Room> rooms, String choosedSchedule) throws RuntimeException {
Byte id = -1;
for(Room room : rooms) {
for(Session session : room.getSessions()) {
for(String schedule : session.getSchedules()) {
if(schedule.equals(choosedSchedule))
id = session.getSessionId();
}
}
}
if(id == -1)
throw new RuntimeException("No se ha encontrado una sesión para ese horario");
return id;
}
private Session getSessionById(List<Room> rooms, Byte id) throws RuntimeException {
Session target = null;
for(Room room : rooms) {
for(Session session : room.getSessions()) {
if(session.getSessionId().equals(id))
target = session;
}
}
if(target == null)
new RuntimeException("No se ha encontrado una sesión con ese ID");
return target;
}
}
public class TicketSeller {
private final List<Room> rooms;
public TicketSeller(List<Room> rooms) {
this.rooms = rooms;
}
public Ticket buyTicket() {
System.out.println("¿Cuál es su nombre?");
String owner = new Scanner(System.in).nextLine();
System.out.println("¿En que horario desea ver la película?");
SessionUtils.showSchedules(rooms);
String schedule = new Scanner(System.in).readLine();
Byte sessionId = SessionUtils.getSessionIdBySchedule(rooms, schedule);
Session session = SessionUtils.getSessionById(rooms, sessionId);
SessionSeats seats = session.getSessionSeats();
seats.showSeats(); // muestra los asientos disponibles
System.out.println("¿Qué asiento desea? Ingresar las coordenadas así: X-Y");
String[] coordinates = new Scanner(System.in).readLine().split("-");
Integer row = coordinates[0];
Integer column = coordinates[1];
seats.reserveSeat(row, column)
Integer[] seat = new Integer[] { row, column};
Ticket ownerTicket = new Ticket(owner, session, schedule, seat);
return owerTicket;
}
}