How to read an excel file contents on client side?

An xlsx spreadsheet is a zip file with a bunch of xml files in it. Using something like zip.js, you can extract the xml files and parse them in the browser. xlsx.js does this. Here’s my simple example. Copied here for convenience: /* Relies on jQuery, underscore.js, Async.js (https://github.com/caolan/async), and zip.js (http://gildas-lormeau.github.com/zip.js). Tested only in … Read more

How to create user-friendly and seo-friendly urls in jsf?

If this is intended as an improvement of an existing application, then you basically need a Filter which detects “dirty” and “friendly” URLs. When it detects a “dirty” URL, then it should redirect the request to a “friendly” URL by HttpServletResponse#sendRedirect(). When it detects a “friendly” URL, then it should forward the request to the … Read more

How can i access javascript variables in JSP?

JavaScript variable is on client side, JSP variables is on server side, so you can’t access javascript variables in JSP. But you can store needed data in hidden fields, set its value in client and get it on server over GET or POST. Client side: <script type=”text/javascript”> var el = document.getElementById(“data”); el.value = “Needed_value”; </script> … Read more

How to iterate HashMap using JSTL forEach loop? [duplicate]

Try this, suppose my MAP is :- Map<String, String> countryList = new HashMap<String, String>(); countryList.put(“United States”, “Washington DC”); countryList.put(“India”, “Delhi”); countryList.put(“Germany”, “Berlin”); countryList.put(“France”, “Paris”); countryList.put(“Italy”, “Rome”); request.setAttribute(“capitalList”, countryList); So in JSP , <c:forEach var=”country” items=”${capitalList}”> Country: ${country.key} – Capital: ${country.value} </c:forEach> Hope this helps !

Get anchor from URI

This isn’t possible as clients don’t send the “anchor part” to the server As an example, here’s the exact request that Chrome generated after submitting http://example.com/#foobar (recorded using Wireshark): GET / HTTP/1.1 Host: example.com Connection: keep-alive User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/532.3 (KHTML, like Gecko) Chrome/4.0.223.11 Safari/532.3 Cache-Control: max-age=0 Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Encoding: gzip,deflate … Read more

A Simple AJAX with JSP example

I have used jQuery AJAX to make AJAX requests. Check the following code: <html> <head> <script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js”></script> <script type=”text/javascript”> $(document).ready(function() { $(‘#call’).click(function () { $.ajax({ type: “post”, url: “testme”, //this is my servlet data: “input=” +$(‘#ip’).val()+”&output=”+$(‘#op’).val(), success: function(msg){ $(‘#output’).append(msg); } }); }); }); </script> <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″> <title>JSP Page</title> </head> <body> input:<input id=”ip” … Read more

Help getting image from Servlet to JSP page [duplicate]

You need to write the image as a byte array to the response’s output stream. Something like this: byte[] imageBytes = getImageAsBytes(); response.setContentType(“image/jpeg”); response.setContentLength(imageBytes.length); response.getOutputStream().write(imageBytes); Then in you JSP you just use a standard img element: <img src=”https://stackoverflow.com/questions/1154254/url to your servlet”>