How to install JSTL? The absolute uri: http://java.sun.com/jstl/core cannot be resolved

org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application That URI is for JSTL 1.0, but you’re actually using JSTL 1.2 which uses URIs with an additional /jsp path (because JSTL, who invented EL expressions, was since version 1.1 integrated as part of JSP 2.0 … Read more

How do you return a JSON object from a Java Servlet

Write the JSON object to the response object’s output stream. You should also set the content type as follows, which will specify what you are returning: response.setContentType(“application/json”); // Get the printwriter object from response to write the required json object to the output stream PrintWriter out = response.getWriter(); // Assuming your json object is **jsonObject**, … Read more

What’s the difference between getRequestURI and getPathInfo methods in HttpServletRequest?

I will put a small comparison table here (just to have it somewhere): Servlet is mapped as /test%3F/* and the application is deployed under /app. http://30thh.loc:8480/app/test%3F/a%3F+b;jsessionid=S%3F+ID?p+1=c+d&p+2=e+f#a Method URL-Decoded Result —————————————————- getContextPath() no /app getLocalAddr() 127.0.0.1 getLocalName() 30thh.loc getLocalPort() 8480 getMethod() GET getPathInfo() yes /a?+b getProtocol() HTTP/1.1 getQueryString() no p+1=c+d&p+2=e+f getRequestedSessionId() no S%3F+ID getRequestURI() no /app/test%3F/a%3F+b;jsessionid=S+ID … Read more

Tomcat VS Jetty [closed]

I love Jetty for its low maintenance cost. It’s just unpack and it’s ready to roll. Tomcat is a bit high maintenance, requires more configuration and it’s heavier. Besides, Jetty’s continuations are very cool. EDIT: In 2013, there are reports that Tomcat has gotten easier. See comments. I haven’t verified that.

How to define servlet filter order of execution using annotations in WAR

You can indeed not define the filter execution order using @WebFilter annotation. However, to minimize the web.xml usage, it’s sufficient to annotate all filters with just a filterName so that you don’t need the <filter> definition, but just a <filter-mapping> definition in the desired order. For example, @WebFilter(filterName=”filter1″) public class Filter1 implements Filter {} @WebFilter(filterName=”filter2″) … Read more

Difference between / and /* in servlet mapping url pattern

<url-pattern>/*</url-pattern> The /* on a servlet overrides all other servlets, including all servlets provided by the servletcontainer such as the default servlet and the JSP servlet. Whatever request you fire, it will end up in that servlet. This is thus a bad URL pattern for servlets. Usually, you’d like to use /* on a Filter … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)