Results 1 to 13 of 13
  1. #1
    agusCba is offline Member
    Join Date
    Apr 2010
    Posts
    14
    Rep Power
    0

    Default Trying to print an CSS file from a Servlet !!!...

    Hi to all Java Lovers from Cordoba, Argentina ! :D. Here is my silly problem (at least I think)... I would like to know why the CSS file isn't detect here ???... Or what I should do in order to get it working... As I also would like to include some JS libraries but since this problem, I can't... Hope someone knows... Cheers and blessings ! :d
    Java Code:
     out.println("<html>");
                        out.println("<head>");
                        out.println("<title>Servlet EmpresaVuelos</title>");
                        out.println("<link rel='stylesheet' type='text/css' href='recursos/ext-all.css' />");
                        out.println("</head>");
                        out.println("<body>");
                        out.println("<h1>Servlet EmpresaVuelos at " + request.getParameter("nombre") + "</h1>");
                        out.println("<div class='bordeado' />");
                        out.println("</body>");
                        out.println("</html>");

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: Trying to print an CSS file from a Servlet !!!...

    Use proper html syntax...eg double quotes. See HTML link tag. (And there is no reason to shout eg exclamation points in your title)

  3. #3
    agusCba is offline Member
    Join Date
    Apr 2010
    Posts
    14
    Rep Power
    0

    Default Re: Trying to print an CSS file from a Servlet !!!...

    First of all, I apologize for the exclamations... Now talking about the topic, I don't see any error in the syntax... I know the site you post but I can't see the mistake... Maybe I should put the file in another directory or maybe I am not pointing correctly to the file... Thankx again for your time...

  4. #4
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: Trying to print an CSS file from a Servlet !!!...

    Single:
    Java Code:
    out.println("<link rel='stylesheet' type='text/css' href='recursos/ext-all.css' />");
    vs Double:

    Java Code:
    out.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"recursos/ext-all.css\" />");
    Which one does the above link demonstrate?

  5. #5
    agusCba is offline Member
    Join Date
    Apr 2010
    Posts
    14
    Rep Power
    0

    Default Re: Trying to print an CSS file from a Servlet !!!...

    Ooh !.... I understand... I will try that right now !... I beg God I get this working coz I have a huge delay !!! :(...

  6. #6
    agusCba is offline Member
    Join Date
    Apr 2010
    Posts
    14
    Rep Power
    0

    Default Re: Trying to print an CSS file from a Servlet !!!...

    It didn't work !... I don't what to do... :( Do you want me to post an image from the project structure ?...

  7. #7
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: Trying to print an CSS file from a Servlet !!!...

    Quote Originally Posted by agusCba View Post
    It didn't work !... I don't what to do... :( Do you want me to post an image from the project structure ?...
    Did you change all those single quotes? For example, your div class currently uses the following syntax:

    Java Code:
    out.println("<div class='bordeado' />");

  8. #8
    agusCba is offline Member
    Join Date
    Apr 2010
    Posts
    14
    Rep Power
    0

    Default Re: Trying to print an CSS file from a Servlet !!!...

    Trying to print an CSS file from a Servlet !!!...-nb-jsp.gifYeah... I changed the single quotes... I dunno what to do... There is the project structure... Sorry If this seems a little bit dumb jeje... I will check the forum later...

  9. #9
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: Trying to print an CSS file from a Servlet !!!...

    So the quotes probably aren't the problem then. It was a hunch that - after some research - was incorrect.

    Where is the css file? It has to be in the path relative to the jsp file so the browser can find it - not within a war (unless you have a servlet which outputs css). So if you access your jsp using the following URL:
    http://www.myurl.com/mywar/myjar.jsp
    then based upon your code above your css should be in
    http://www.myurl.com/mywar/recursos/ext-all.css
    If you go to the url above, does this file exist?

  10. #10
    agusCba is offline Member
    Join Date
    Apr 2010
    Posts
    14
    Rep Power
    0

    Question Re: Trying to print an CSS file from a Servlet !!!...

    doWhile !. How's all ???... Sorry for not postinh again... I needed to go downtown !. I started pasting in every folder the "recursos" folder and I manage to get the file content in this url...

    Java Code:
    http://localhost:8080/Web_Modulo_1/recursos/estiloPrincipal.css
    But when I put inside the servlet the following code...
    Java Code:
    out.println("<meta http-equiv='Content-Type' content='text/html' charset=UTF-8'/>");
                        out.println("<html>");
                        out.println("<head>");
                        out.println("<title>Servlet EmpresaVuelos</title>");
                        out.println("<link rel='stylesheet' type='text/css' href='http://localhost:8080/Web_Modulo_1/recursos/estiloPrincipal.css' />");
                        out.println("</head>");
                        out.println("<body>");
                        out.println("<div class='bordeado' style='width:100px;height:100px;background-color:red;'>Hola</div>");
                        out.println("</body>");
                        out.println("</html>");
    I get like stack in the form screen and I don't get nothing... I put some debugging code and I don't get any exception or error... I will keep checking !... Sorry If you waited my answer...

  11. #11
    agusCba is offline Member
    Join Date
    Apr 2010
    Posts
    14
    Rep Power
    0

    Default Re: Trying to print an CSS file from a Servlet !!!...

    Dude... I really don't know what I did... But it works now !... thank you very much for your time !... Thankx again

  12. #12
    agusCba is offline Member
    Join Date
    Apr 2010
    Posts
    14
    Rep Power
    0

    Default Re: Trying to print an CSS file from a Servlet !!!...

    Hey Are you there ?... You know what happened... Although I am able to access css and js files, when I put this code...
    Java Code:
            PrintWriter out = null;
            try
            {
                 out = response.getWriter();
                 out.println("<html>");
                 out.println("<head>");
                 out.println("<title>Servlet EmpresaVuelos</title>");
                     out.println("<link rel='stylesheet' type='text/css' href='http://localhost:8080/Web_Modulo_1/recursos/estiloPrincipal.css' />");
                     out.println("<link rel='stylesheet' type='text/css' href='http://localhost:8080/Web_Modulo_1/recursos/ext-all.css' />");
                     out.println("<script type='text/javascript' src='http://localhost:8080/Web_Modulo_1/recursos/ext-base.js'/>");
                     out.println("<script type='text/javascript' src='http://localhost:8080/Web_Modulo_1/recursos/ext-all-debug.js' />");             
                     out.println("<script type='text/javascript' src='http://localhost:8080/Web_Modulo_1/recursos/prueba.js'/>");                                                    
                 out.println("</head>");
                 out.println("<body>");
                     out.println("<img src='http://localhost:8080/Web_Modulo_1/recursos/4.jpg' ></img>");
                     out.println("<div class='bordeado' style='width:100px;height:100px;' />");
                 out.println("</body>");
                 out.println("</html>");            
            }
            catch(IOException io)
            {
                
            }
    I don't get anything... But if I use src from the image above, I am able to see it in the browser... It's like I don't let say... rights to access them !... Do you have any idea why is this ?... Thankx

  13. #13
    agusCba is offline Member
    Join Date
    Apr 2010
    Posts
    14
    Rep Power
    0

    Default Re: Trying to print an CSS file from a Servlet !!!...

    I add more... When I try to see the html code when the page is render, I get nothing... This is something really weird...

Similar Threads

  1. Print to File Java
    By snambu in forum AWT / Swing
    Replies: 0
    Last Post: 07-27-2010, 04:22 PM
  2. Print .prn file using java
    By nishant in forum Advanced Java
    Replies: 0
    Last Post: 07-14-2009, 10:15 AM
  3. Replies: 6
    Last Post: 06-05-2009, 12:09 AM
  4. Replies: 0
    Last Post: 08-30-2008, 12:52 PM
  5. Print the text file and print preview them
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-23-2008, 12:04 AM

Tags for this Thread

Posting Permissions

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