import com.prueba.controllers.Controller;
import com.prueba.core.http.sessions.SessionContext;
import com.prueba.core.http.sessions.SessionInfo;
-import com.prueba.view.page.PageImpl;
+import com.prueba.view.PageImpl;
import com.sun.net.httpserver.HttpExchange;
public class PagesController implements Controller {
import com.prueba.core.http.sessions.SessionInfo;
import com.prueba.core.http.sessions.Sessions;
import com.prueba.model.dao.AccountDao;
-import com.prueba.view.login.LoginFormImpl;
+import com.prueba.view.LoginFormImpl;
import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpExchange;
}
httpExchange.sendResponseHeaders(200, html.length());
-
try (final OutputStream os = httpExchange.getResponseBody()) {
os.write(html.getBytes());
}
--- /dev/null
+package com.prueba.view;
+
+import static org.rendersnake.HtmlAttributesFactory.for_;
+import static org.rendersnake.HtmlAttributesFactory.id;
+import static org.rendersnake.HtmlAttributesFactory.type;
+
+import java.io.IOException;
+
+import org.rendersnake.HtmlCanvas;
+
+public class LoginFormImpl {
+ private static final String ID_USERNAME = "username";
+ private static final String ID_PASSWORD = "password";
+ private static final String VAR_USERNAME = "username";
+ private static final String VAR_PASSWORD = "password";
+
+ public String doNoRequiredLogin() throws IOException {
+ final HtmlCanvas html = new HtmlCanvas();
+ return html
+ .html()
+ .body()
+ .h1().content("NO REQUIRED LOGIN")
+ ._body()
+ ._html()
+ .toHtml();
+ }
+
+ public String doRequiredLogin(String requestedURI) throws IOException {
+ final HtmlCanvas html = new HtmlCanvas();
+ return html
+ .html()
+ .form(id("sample").action(requestedURI).method("post"))
+ .label(for_(ID_USERNAME)).write("Username:")._label()
+ .input(
+ id(ID_USERNAME)
+ .name(VAR_USERNAME))
+ .br()
+ .label(for_(ID_PASSWORD)).write("Password:")._label()
+ .input(
+ type("password")
+ .id(ID_PASSWORD)
+ .name(VAR_PASSWORD))
+ .br()
+ .input(type("submit").value("Log me in"))
+ ._form()
+ .toHtml();
+ }
+}
--- /dev/null
+package com.prueba.view;
+
+import static org.rendersnake.HtmlAttributesFactory.href;
+
+import java.io.IOException;
+
+import org.rendersnake.HtmlCanvas;
+
+public class PageImpl {
+
+ public String doPage(int number, String userName) throws IOException {
+ final HtmlCanvas html = new HtmlCanvas();
+ return html
+ .html()
+ .body()
+ .h1().content("PAGE: " + number)
+ .h1().content("Hello " + userName)
+ .h1().a(href("/app/login/logout.html")).write("Logout")._a()._h1()
+ ._body()
+ ._html()
+ .toHtml();
+ }
+
+}
+++ /dev/null
-package com.prueba.view.login;
-
-import static org.rendersnake.HtmlAttributesFactory.for_;
-import static org.rendersnake.HtmlAttributesFactory.id;
-import static org.rendersnake.HtmlAttributesFactory.type;
-
-import java.io.IOException;
-
-import org.rendersnake.HtmlCanvas;
-
-public class LoginFormImpl {
- private static final String ID_USERNAME = "username";
- private static final String ID_PASSWORD = "password";
- private static final String VAR_USERNAME = "username";
- private static final String VAR_PASSWORD = "password";
-
- public String doNoRequiredLogin() throws IOException {
- final HtmlCanvas html = new HtmlCanvas();
- return html
- .html()
- .body()
- .h1().content("NO REQUIRED LOGIN")
- ._body()
- ._html()
- .toHtml();
- }
-
- public String doRequiredLogin(String requestedURI) throws IOException {
- final HtmlCanvas html = new HtmlCanvas();
- return html
- .html()
- .form(id("sample").action(requestedURI).method("post"))
- .label(for_(ID_USERNAME)).write("Username:")._label()
- .input(
- id(ID_USERNAME)
- .name(VAR_USERNAME))
- .br()
- .label(for_(ID_PASSWORD)).write("Password:")._label()
- .input(
- type("password")
- .id(ID_PASSWORD)
- .name(VAR_PASSWORD))
- .br()
- .input(type("submit").value("Log me in"))
- ._form()
- .toHtml();
- }
-}
+++ /dev/null
-package com.prueba.view.page;
-
-import static org.rendersnake.HtmlAttributesFactory.href;
-
-import java.io.IOException;
-
-import org.rendersnake.HtmlCanvas;
-
-public class PageImpl {
-
- public String doPage(int number, String userName) throws IOException {
- final HtmlCanvas html = new HtmlCanvas();
- return html
- .html()
- .body()
- .h1().content("PAGE: " + number)
- .h1().content("Hello " + userName)
- .h1().a(href("/app/login/logout.html")).write("Logout")._a()._h1()
- ._body()
- ._html()
- .toHtml();
- }
-
-}