/styles/
+style1.css
+style2.css
+style3.css
And you will have in your .html like this:
<link type="text/css" rel="stylesheet" href="/styles/style1.css">
<link type="text/css" rel="stylesheet" href="/styles/style2.css">
<link type="text/css" rel="stylesheet" href="/styles/style3.css">
Then you need 3 request for download the styles file.
With this servlet you can reduce to 1 request for download "the union" of the three files if you put:
<link type="text/css" rel="stylesheet" href="/styles/cssServlet.css">
This URL map with the servlet.
Juan
2011/2/23 Deepak Singh <deepaksingh.kr@gmail.com>
what is this cssServlet.css ?On Thu, Feb 24, 2011 at 1:22 AM, Juan Pablo Gardella <gardellajuanpablo@gmail.com> wrote:
In your html:/styles/cssServlet.cssIn web.xml:<servlet-mapping><servlet-name>cssServlet</servlet-name><url-pattern>/styles/cssServlet.css</url-pattern></servlet-mapping>Juan2011/2/23 Deepak Singh <deepaksingh.kr@gmail.com>Hi Jaun,How to use this CssServlet class ?--On Wed, Feb 23, 2011 at 9:14 PM, Juan Pablo Gardella <gardellajuanpablo@gmail.com> wrote:
Hi,Try that (thanks Gabriel Nossier):public class CssServlet extends HttpServlet {private static final long serialVersionUID = 2545846261709821197L;private static final String path1 = "./";private static final String path2 = "webapps/styles/";/** (non-Javadoc)** @see* javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest* , javax.servlet.http.HttpServletResponse)*/@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {doPost(req, resp);}/** (non-Javadoc)** @see* javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest* , javax.servlet.http.HttpServletResponse)*/@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {resp.setContentType("text/css");PrintWriter out = resp.getWriter();out.println("@CHARSET \"ISO-8859-1\";");generateMonoliticCssFile(out);out.close();}private void generateMonoliticCssFile(PrintWriter out) throws IOException {File dir = new File(path1);if (dir.exists()) {listFolder(out, dir);} else {dir = new File(path2);if (dir.exists()) {listFolder(out, dir);} else {out.println("Paths '" + path1 + "' and ' " + path2 + "' doesn't exists");File local = new File(".");out.println("Local path:" + local.getAbsolutePath());}}}private void listFolder(PrintWriter out, File dir) throws IOException {for (File file : getAllCssFiles(dir)) {process(out, file);}}/*** @param out* @param file* @throws IOException*/private void process(PrintWriter out, File file) throws IOException {out.println("");out.println("/****** file:" + file.getName() + " *******/");out.println("");BufferedReader fileReader = new BufferedReader(new FileReader(file));String aLine = null;while ((aLine = fileReader.readLine()) != null) {if (!aLine.startsWith("@CHARSET")) {out.println(aLine);}}out.println("");}/*** @param dir* @return*/private List<File> getAllCssFiles(File dir) {List<File> rv = new LinkedList<File>();FilenameFilter filenameFilter = new FilenameFilter() {@Overridepublic boolean accept(File dir, String name) {return name.toLowerCase().endsWith(".css");}};for (File file : dir.listFiles(filenameFilter)) {rv.add(file);}return rv;}}2011/2/23 Deepak Singh <deepaksingh.kr@gmail.com>
--Hi,After compiling our gwt project we get one statndard.css file which loads to the client consuming 1 http request.We also have our application specific style.css file which loads consuming 1 seperate http request.To reduce the number of http requests, how should i combine them into 1 css file ?Also, we have many application specific images which loads to the client using 1 http request for 1 image. If i create 1 ImageBundle and put all images into this bundle, how do i get this bundle loaded to the client in just 1 http request at the application start up time ?ThanksYou received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment