Showing posts with label Web Application Development. Show all posts
Showing posts with label Web Application Development. Show all posts

Tuesday, October 6, 2009

How to make a browser open a pdf as an attachment

You need to set the header 'content-disposition' to attachment, e.g.

content-disposition: attachment;filename=detailedstatement_167.pdf;, inline

Otherwise content-disposition is set to inline which means the browser will open it in the browser window, as if you'd clicked on a link and gone to another page.

How to get the root context of a web application

<%=request.getContextPath()%>



Or with jstl:



<c:out value="${pageContext.request.contextPath}">



For portlets you can also use renderRequest.contextPath, however the page must have include <portlet:defineObjects/>

Saturday, July 18, 2009

How do I get jQuery to select elements with a . (period) in their ID?


Use two backslashes before each special character.

A backslash in a jQuery selector escapes the next character. But you need two of them because backslash is also the escape character for JavaScript strings. The first backslash escapes the second one, giving you one actual backslash in your string - which then escapes the next character for jQuery.