Results 1 to 3 of 3
  1. #1
    SaintShion is offline Member
    Join Date
    Nov 2011
    Posts
    4
    Rep Power
    0

    Question importing style (css) with servlet

    Hello! I'm not able to use css in my servlet pages.
    The style does not appear = S


    Java Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package ServletCliente;
    
    import com.diva.model.Cliente;
    import com.diva.model.ClienteDao;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    public class ViewAllServletC extends HttpServlet {
    
        /** 
         * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
         */
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            try {
    
                out.println("<html>");
                out.println("<head>");
                out.println("<title>Diva</title>");
    
                //out.println("<link rel='stylesheet' href='/styles/style.css' type='text/css'>"); 
                out.println("<link href=styles/style.css rel=stylesheet type=text/css>"); 
                //out.println("<link rel="+"stylesheet"+" type="+"text/css");
                //out.println("href=" + request.getContextPath() +  "/styles/style.css/>");     
                //out.println("</style>");
                
                
                out.println("</head>");
                out.println("<body>");
    
                out.println("<div id=\"wrap\">");
                out.println("<div id=\"header\">");
    
                out.println("<h2>Sistema de informação para salões de beleza</h2>");
                out.println("<div id=\"nav\">");
                out.println("<ul id=\"nav-pages\">");
                out.println("<li><a href=\"inicio.html\">Início</a><span>/</span></li>");
    
                out.println("</ul>");
                out.println("</div>");
                out.println("</div>");
    
                out.println("<h1>Clientes Cadastrados:</h1>");
    
    
                out.println("<div id=\"main\">");
                out.println("<ul id=\"content\">");
                out.println("<div id=\"featured-projects\">");
                out.println("<div id=\"featured-projects-bg\">");
                out.println("<div align=\"left\">");
    
    
                out.println("<table border=\"0\">");
                out.println("<tr>");
                out.println("<td width=\"100\"><b>Nome</b></td>");
                out.println("<td width=\"200\"><b>Sobrenome</b></td>");
                out.println("<td width=\"300\"><b>Telefone Residencial</b></td>");
                out.println("<td width=\"400\"><b>Telefone Celular</b></td>");
    
                out.println("<td width=\"500\"><b>Editar</b></td>");
                out.println("<td width=\"500\"><b>Remover</b></td>");
                out.println("</tr>");
    
                ClienteDao dao = new ClienteDao();
                for (Cliente c : dao.getLista()) {
                    System.out.println("Cliente: " + c.getNome());
                    out.println("<tr>");
                    out.println("<td>" + c.getNome() + "</td>");
                    out.println("<td>" + c.getSnome() + "</td>");
                    out.println("<td>" + c.getTelres() + "</td>");
                    out.println("<td>" + c.getTelcel() + "</td>");
                    out.println("<td><a href =\"./FrmEdit?id=" + c.getId() + "\">Editar </a></td>");
                    out.println("<td><a href =\"./Remover?id=" + c.getId() + "\">Remover </a></td>");
                    out.println("</tr>");
                }
    
                out.println("</table>");
    
                out.println("</div>");
                out.println("</div>");//featured-projects-bg
                out.println("</div>");//end featured-projects
                out.println("</div>");//end content
                out.println("</div>");//end main
                out.println("</div>");//end wrap
    
    
                out.println("</body>");
                out.println("</html>");
    
            } finally {
                out.close();
            }
        }
    
        // <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>
    }
    importing style (css) with servlet-sem-t-tulo.jpg


    Thank you
    Last edited by SaintShion; 04-22-2012 at 06:18 PM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default Re: importing style (css) with servlet

    That's not going to be a servlet thing.
    It'll be enitrely down to what the HTML looks like at the client and where the styles.css is on the server.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    SaintShion is offline Member
    Join Date
    Nov 2011
    Posts
    4
    Rep Power
    0

    Default Re: importing style (css) with servlet

    Hello! I solved the problem, thanks :)

    Java Code:
    out.println("<link rel='stylesheet' type='text/css' href='" + request.getContextPath() +  "/styles/style.css' />");

Similar Threads

  1. Style of writing
    By tnrh1 in forum New To Java
    Replies: 2
    Last Post: 02-16-2012, 03:28 PM
  2. Artistic Style 2.02.1
    By java software in forum Java Software
    Replies: 0
    Last Post: 12-24-2011, 06:00 PM
  3. Google Style Button - Has it been done before?
    By SilentSoul in forum AWT / Swing
    Replies: 9
    Last Post: 10-13-2011, 03:42 AM
  4. importing C++ dll to servlet
    By shwein in forum Java Servlet
    Replies: 0
    Last Post: 04-15-2010, 10:23 AM
  5. Cascading Style Sheets
    By smart in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 12-27-2008, 05:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •