Results 1 to 5 of 5
- 04-22-2012, 05:35 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 4
- Rep Power
- 0
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> }
Thank youLast edited by SaintShion; 04-22-2012 at 07:18 PM.
- 04-23-2012, 11:57 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
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 **
- 04-24-2012, 03:36 AM #3
Member
- Join Date
- Nov 2011
- Posts
- 4
- Rep Power
- 0
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' />");
- 07-25-2016, 07:41 AM #4
Member
- Join Date
- Jul 2016
- Posts
- 1
- Rep Power
- 0
Re: importing style (css) with servlet
how did you solved it? i have the same problem
- 07-25-2016, 10:00 AM #5
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
Similar Threads
-
Style of writing
By tnrh1 in forum New To JavaReplies: 2Last Post: 02-16-2012, 04:28 PM -
Artistic Style 2.02.1
By java software in forum Java SoftwareReplies: 0Last Post: 12-24-2011, 07:00 PM -
Google Style Button - Has it been done before?
By SilentSoul in forum AWT / SwingReplies: 9Last Post: 10-13-2011, 04:42 AM -
importing C++ dll to servlet
By shwein in forum Java ServletReplies: 0Last Post: 04-15-2010, 11:23 AM -
Cascading Style Sheets
By smart in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 12-27-2008, 06:25 PM
Bookmarks