Ir ao conteúdo
  • Cadastre-se

Projeto java


Posts recomendados

Podem me ajudar com o exercicio em anexo eu ja fiz algumas partes, só que estou com muitas duvidas.

 

Arquivo html (CadastroFunc)

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <form action='Funcionario.java' method='get'>
            Nome: <input type= text name='Nome'><br>
            Sobrenome: <input type=text name='Sobrenome'><br>
            Salario: <input type="text" name="Salario"><br>
            Gratificacao: <input type="text" name="Gratificacao"><br>
        <input type=submit value='Cadastrar'>
       
        </form>  
    </body>
</html>


 

cabeçalho (JSP)

 

 

<%-- 
    Document   : cabeçalho
    Created on : 04/11/2016, 20:35:01
    Author     : aluno
--%>
<%@page import="java.util.*, java.text.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Sao Jose</title>
    </head>
    <body>
        <h1>
            
            <%!
public  String fncMES(int mes)
{
    String retorno ="";
    switch(mes){
        case 1: retorno="Janeiro";break;
        case 2: retorno="Fevereiro";break;
        case 3: retorno="Março";break;
        case 4: retorno="Abril";break;
        case 5: retorno="Maio";break;
        case 6: retorno="Junho";break;
        case 7: retorno="Julho";break;
        case 8: retorno="Agosto";break;
        case 9: retorno="Setembro";break;
        case 10: retorno="Outubro";break;
        case 11: retorno="Novembro";break;
        case 12: retorno="Dezembro";break;
    }
    return retorno;
    }
%>
            <%
int mes = Integer.parseInt(new SimpleDateFormat("M").format(new Date()));
int dia = Integer.parseInt(new SimpleDateFormat("dd").format(new Date()));
int ano = Integer.parseInt(new SimpleDateFormat("yyyy").format(new Date()));
out.println("Faculdades São Jose, " + dia + " de " + fncMES(mes) + " de " + ano);
%>
    </body>
</html>


 

index.JSP


 

<%-- 
    Document   : index
    Created on : 04/11/2016, 19:30:33
    Author     : aluno
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        
        <h1>
            <%@page import="java.util.*, java.text.*" %>
            <%
        out.println("<h1>Bem-Vindo,</h1>");
        int dia = Integer.parseInt((new SimpleDateFormat("dd")).format(new Date()));
        int mes = Integer.parseInt((new SimpleDateFormat("M")).format(new Date()));
        int ano = Integer.parseInt((new SimpleDateFormat("yyyy")).format(new Date()));
       
           out.println("Data, " + dia + " de " + mes + " de " + ano);
           
    %>
            </h1>
        <form action='Logar' method='get'>
        Usuário: <input type="text" name='Usuario'><br>
        Senha: <input type="text" name='Senha'><br>
        <input type=submit value='Login'>
        </form>    
        <h3>Copyrigth Eu</h3>
    </body>
</html>

Rodape.JSP


 

<%-- 
    Document   : rodape
    Created on : 04/11/2016, 20:35:19
    Author     : aluno
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Copyrigth</title>
    </head>
    <body>
        <h1>Hello World!</h1>
    </body>
</html>

Pacotes

Funcionario.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author aluno
 */
public class Funcionario {
    private String nome;
    private String sobrenome;
    private Double salario;
    private Double gratificacao;
    public String getNome() {
        return nome;
    }
    public void setNome(String nome) {
        this.nome = nome;
    }
    public String getSobrenome() {
        return sobrenome;
    }
    public void setSobrenome(String sobrenome) {
        this.sobrenome = sobrenome;
    }
    public Double getSalario() {
        return salario;
    }
    public void setSalario(Double salario) {
        this.salario = salario;
    }
    public Double getGratificacao() {
        return gratificacao;
    }
    public void setGratificacao(Double gratificacao) {
        this.gratificacao = gratificacao;
    }
    
    
   
    
    
}


 

Logar.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 *
 * @author aluno
 */
    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @WebServlet(urlPatterns = {"/Logar"})
    public class Logar extends HttpServlet {
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
            /* TODO output your page here. You may use following sample code. */
            Login login = new Login();
            String Usuario = request.getParameter("Usuario");
            String Senha = request.getParameter("Senha");
            
            login.setUsuario(Usuario);
            login.setSenha(Senha);
         
            
            out.println("<!DOCTYPE html>");
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet Logar</title>");            
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Data</h1>");
            out.println("<h1>bem-vindo,  " + login.getUsuario()+ "</h1>");
            out.println("<h4>Escolha uma Opcao</h4>");
            
            out.println("</body>");
            out.println("</html>");
        }
    }
    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }
    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }
    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}

Login.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author walqu
 */
public class Login {
    private String login;
    private String Senha;
    public String getLogin() {
        return login;
    }
    public void setLogin(String login) {
        this.login = login;
    }
    public String getSenha() {
        return Senha;
    }
    public void setSenha(String Senha) {
        this.Senha = Senha;
    }
    String getUsuario() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    void setUsuario(String Usuario) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
    
}

POO2_ExercicioServletJSP.pdf

adicionado 0 minutos depois

Estou utilizando o netbeans

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...