servlets

Issue with JSF ViewExpiredException and multiple error-page tag definitions in web.xml

I'm working on a JSF web application in which I need to bring up a "Session Expired" page if the view expires, but a general technical error page for all others. The application only goes to the technical error page when I trigger the exception. Here's the error-page definitions: <error-page> <exception-type>javax.faces.applicati...

What is the JSP equivalent to json_encode ( in PHP ) ?

I am trying to encode a JSP servlet into JSON. What's the equivalent in JSP to json_encode() in PHP ? ...

Tomcat intermittently servicing requests

Hello, I recently switched my web application from running via an embedded Jetty instance to a standalone Tomcat instance. Everything is mapped appropriately, and Tomcat begins to serve up content. However, my application makes about 20 AJAX POST requests at once to the server (to load various page elements). This worked fine on Jetty,...

Adding another item to collection object

State: <html:select property="product.stateId" size="1" onchange="loadProducts();loadProducts2();"> <html:options collection="stateList" property="id" labelProperty="name"/> </html:select> I want to add another option to the list of states such as, "Please select state," in the drop down menu. I think I need to modify the Java col...

jquery .load() and IE

Hi there, Tested the below code with FF, Safary and Chrome and all works ok. But with IE... not so When the button "viewEditButID'" is click the div "customerDetailsDivClass" is hidden. When it's click again the div reapers but before it dose so it download the data is going to display. $(document).ready( function() { $('#viewEditButID...

Spring servlet for serving static content?

I'm wondering what's the Spring way of serving static files. It should support: Written in a Springy way! Simple and reliable Support for resuming downloads (eg. Range request header, and Accept-Ranges, ETag and Last-Modified response headers). Support for client-side caching (eg. If-None-Match and If-Modified-Since request headers, an...

How to get and set a global object in Java servlet context

Hello I wonder if anyone can advise: I have a scenario where a scheduled job being run by Quartz will update an arraylist of objects every hour. But I need this arraylist of objects to be visible to all sessions created by Tomcat. So what I'm thinking is that I write this object somewhere every hour from the Quartz job that runs so th...

Caching contents of a page?

Hi, I'm generating page content like: // index.jsp <% List<Horse> horses = database.getHorses(); for (Horse it : horses) { %> <div><%= it.getName() %></div> <% } %> is it possible to grab the entire page content at the end of the jsp file, and dump it into a String, like: String page = this.getPrin...

website offline jsp

Hi!!! =) I am creating a website using jsp, ajax, servlets. My framework is prototype. The connection is bad, so I would like my web application to respond correctly in situations like this. For example to give a message indicating you are working offline, and to report when plugged in again and can continue. The solution should wo...

Getting 'global' variables from other jsp pages?

Hi, Can a variable declared in one jsp file be used in another, if imported? Example: // index.jsp <% int count = 40; %> <%@include file='go.jsp'%><% // go.jsp <% count += 10; %> is count visible to go.jsp? I am guessing this is not good design anyway (expecting global variables to be around for you from another page), just wonder...

cvc-id.3 error in web.xml

I'm getting this error message while editing web.xml file in eclipse for SpringMVC web-app: cvc-id.3: A field of identity constraint 'web-app-servlet-name-uniqueness' matched element 'web-app', but this element does not have a simple type. here is part of my web.xml: <?xml version="1.0" encoding="UTF-8" ?> <web-app xmlns:...

Servlet POST parameters null

I want a servlet to print the parameters from a html form but in the servlet the request has no parameters. <form method="post" action="LoginServlet" > <input type="text" name="username" id="username" /><br/> <input type="text" name="password" /><br/> <input type="submit" /> </form> and the servlet's doPost(): protected v...

forward()/redirect() usage for a signup process?

Hi, I'm trying to finalize a signup process for my webapp, but am getting confused with servlet forwarding/redirects (again). The flow looks like this: // /signup/index.jsp <form action='/user/signup'> </form> <% if (request.getAttribute("msg") != null) { %><div><%= request.getAttribute("msg") %><% } %> // Servlet which maps to '...

Use of variables in ServletContextListener

Is there any reason why a variable can't be created in a Java ServletContextListener and it's value set and get like any other. What I have is an ArrayList in an SCL and a method in another class updates the ArrayList every so often using static get and set methods in the SCL itself. My preference here is not to use ServletContext to sto...

how to over ride request object in ServletRequestWrapper?

I want to over ride the default getParameter() method of ServletRequestWrapper with getParameter() method of SecurityRequestWrapper. For example, if I am using a simple jsp form to take the name of a person, String name = request.getParameter("firstName"); I want the above getParameter() method to be from the SecurityRequestWrapper ...

Web.xml - url pattern mapped twice

A web.xml of ours contains following excerpt.. <servlet> <servlet-name>testServlet</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>testServlet</servlet-name> <url-pattern>*.ht...

Slow XML response in Java Servlet with MySQL connector

Hi, I created a Java Servlet that get query result from mySQL database and print it in XML format. the problem is that it takes a very long time, something about three minutes to print the xml result while in my PHP script it takes 5 seconds. My Servlet relevant function is: ( run a query and return the xml in a String variable, then, p...

Efficient access to HttpServletRequest for debug prints

Hello, In order to debug failing requests I would like to print all information coming from HttpServletRequest. Now, it's possible that a request will partially fail (for ex. Several matches are successful, yet one has failed) in which case I would like to catch the exception in the internal method that failed, print the error + the S...

login to servlet over SSL

Hi folks. I currently have a RESTful servlet running that returns json upon receiving a POST query. I would like to implement authentication over SSL, so that the user will first login and send his credentials so the servlet knows what level of authorization it has to return the data, but I'm not sure how to go about implementing this fo...

How do I make use of the google active robot API to react to other servlet actions?

I'm trying to create a wave robot that reacts to outside events, To do this, I have a program that POST's data to an HTTPServlet, which then processes the data into a usable form. I then somehow need to send this data to my robot wavelet so that it can make the changes to google wave. The problem is that the method of obtaining other ser...