Results 1 to 3 of 3
  1. #1
    hannehomuth's Avatar
    hannehomuth is offline Member
    Join Date
    Jul 2008
    Location
    Sommerfeld (Brandenburg, Germany)
    Posts
    36
    Rep Power
    0

    Default [SOLVED] Use Tablib in a servlet

    Hi @all,

    I want to use a the Apache Tiles 2 TagLib in an servlet. I mean the page which is generated uses some Tiles 2 Tags, and therefor I have to use this taglib. But how can I get this taglib in my servlet.

    Java Code:
    public class ProjectDetails extends HttpServlet {
       
        /** 
        * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
        * @param request servlet request
        * @param response servlet response
        */
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            try {
                
               //out.println("<%@ taglib uri=\"http://tiles.apache.org/tags-tiles\" prefix=\"tiles\" %>;");
               out.println("<html>" +
                            "<head>" +
                            "<meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\">" +
                            "<link href=\"css/layout.css\" type=\"text/css\" rel=\"stylesheet\">" +
                            " <title>AIS DCL</title>" +
                            "</head>" +
                            "<body>" +
                            "<tiles:insertDefinition name=\"aisdcl.projectAdminView\" />" +
                            "</body>" +
                            "</html>");
                
            } finally { 
                out.close();
            }
        }
    This line out.println("<%@ taglib uri=\"http://tiles.apache.org/tags-tiles\" prefix=\"tiles\" %>;"); will not work, because the writer writes it in html and it will not get compiled or whatever. But how can I use this taglib in my servlet????

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    757
    Rep Power
    7

    Default

    What I understand that the taglib technology is used inside a JSP file and not a Servlet. Is there other way that you can think of so that the page is not created by Servlet but simply a JSP file?

  3. #3
    hannehomuth's Avatar
    hannehomuth is offline Member
    Join Date
    Jul 2008
    Location
    Sommerfeld (Brandenburg, Germany)
    Posts
    36
    Rep Power
    0

    Default I can take a jsp file

    Hello wsaryada,

    thank you for your reply. Actually I did like you sad. I only forgot to post my soulution here. Sorry for that. And now that I understand the jsp concept better I know that a jsp file will be always compiled to a servlet. And thats why now matter about that. And furthermore taking a jsp file is better than use this f*****g out.println("<img scr=\"blabla\"...>); (only a example :) in a servlet). Thank you very much.

Similar Threads

  1. servlet
    By kondalrao.p in forum Java Servlet
    Replies: 1
    Last Post: 09-06-2008, 01:10 PM
  2. Servlet
    By banie in forum New To Java
    Replies: 6
    Last Post: 04-11-2008, 05:18 PM
  3. How to mix servlet & JSP
    By Swamipsn in forum Java Servlet
    Replies: 1
    Last Post: 08-08-2007, 12:57 AM
  4. Replies: 1
    Last Post: 08-07-2007, 03:47 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
  •