servlets

synchronize servlet sessions

I've created a web app that uses OAuthentication to log in to Twitter and the login process works successfully on a single servlet. On that servlet I get the session for the user. However, once I move to another servlet for the first time and try to get the session again, a new one is created. I thought the web app would read client co...

Find number of active sessions created from a given client IP

Is there a way to determine the number of active sessions created from a given client IP address? ...

How do you force a download prompt, before data it sent from a servlet?

Hi all, How do you force a download prompt to popup before you send any data to browser? I know about content disposition attachment, but this is different. Basically, the servlet starts sending data to the client, and then the client open a dialog, open, save, cancel. The probably is my servlet is slow getting the data, and it gets ...

Is there a means of executing code during the startup of Apache Tomcat 6.x to perform intialization routines, etc.?

I want to initialize a global instance of a class before my Tomcat server completes startup and begins to offer my servlets. If this service somehow fails initialization, I'd like the entire startup sequence to fail as well (or as close to this as possible; it would be pointless for the server to be running otherwise). What's the best ...

How to implement "remember me" for tomcat JndiRealm form authentication?

I have a webapp running on tomcat using a JndiRealm and form authentication. I would like to add a "remember me" checkbox to that form. What is the best way to do this? ...

how to import a jsp from temp directory in jstl

I have some dynamically generated jsp content I'd like to (jstl) c:import into another jsp page. Currently I have the dynamically generated jsp written to a file in the servlet temp directory (javax.servlet.context.tempdir) but can't work out how I can import it since it is outside the servlet context. Is there a way to import a jsp from...

How to open a pop-up page and render a JSF Response ?

I am using JSF 1.2 without any component libs for a JSF Application. Consider a case where I have a JSF rendered page and on click of a link in that page,a pop-up page should open and show some details which are from the backing bean? What are the options? since the pop up page is just a look up (read only data) , I am thinking to use ja...

Confusion with RequestDispatcher saying the browser address bar does not change

All the online references and head first JSP&Servlet book I'm reading state the characteristic of RequestDispatcher and Redirect (i.e. resoponse.sendRedirect() ) like: "Request Dispatcher" - URL in the browser bar does not change. "Redirect" - The user sees the new URL in the browser. But according to my test, for RequestDispatcher, I...

J2EE: Singleton vs keeping things in session

When should an object (i.e. an application-wide properties file) be kept in the session, as opposed to creating a singleton to keep it? When should each of these approaches be used? Note: I am working on a clustered environment, if that makes any difference. ...

Servlet filter url mapping

How can a filter be mapped to the root of a URL? I'm using Tomcat 7.0.2 and deploying an application as ROOT.war. The welcome page is sign_in.xhtml. I would like to run a filter whenever the client sends a request for the root of the site (i.e. the domain name only), or when the the client requests sign_in.xhtml. Here is what I have s...

With java/j2ee, how does serialization work and in relation to saving that object in session?

If I have a complex object with hundreds of String fields and objects of objects. Some are implementing Serializable and some aren't. How would a j2ee server serialize that data in session. Would I expect all data to be returned. Even the objects of objects. Session.setAttribute(data) E.g. Session.getAttribute() == data.getData().g...

applying JSP/JSTL's <c:url> to a path inside a servlet

In our JSP pages, we use extensively. Works great, rewrites the URL to deal with sessionids, contexts, etc. But now we need to do some of this work inside a class that takes an HttpServletRequest and HttpServletResponse as part of the Spring Security specification. How do I apply a type transformation to a path in a servlet? I gues...

Session Lost when closing the browser.

Hi, I setup my Session time out. <session-config> <session-timeout>11520</session-timeout> </session-config> Each time when I close the browser and open it again by calling the servlet, I see that new session is created. It can be seen from SessionCreated method executed in HttpSessionListener each time when browser reopened. I'm...

Howto get rid of <mvc:annotation-driven />?

Up to now, <mvc:annotation-driven /> has caused plenty of trouble for me, so I would like to get rid of it. Although the spring framework docs clearly say what it is supposed to be doing, a listing of tags actually summar <mvc:annotation-driven /> is lacking. So I'm stuck with removing <mvc:annotation-driven /> and now getting the erro...

JDO Google App Engine validate user

I've been following the google app engine tutorial and the part that explains JDO is done under the basis of a guestbook. So when they query the persistence (BigTable i believe) they are interested in returning all the results. I'm trying to adapt this for showing the results for the specific user but seem to be having trouble with it. ...

Choosing an appropriate url pattern for Sitemesh to exclude my servlet from its decorators?

I configured my Spring web app with a servlet to serve images at the URL: /imgsrv?imgid=12345 I also have Sitemesh installed and now when I call this image servlet, I get a decorator exception related to this servlet, which does not need a decorator applied to it. According to the Sitemesh docs, you can exclude certain URLs from havi...

How to rectify the following error while using Servlet??

I am learning Servlets concept. Initially, I Tutorial referred to this link and working on the HelloWorld example. On submission of the JSP form with the name and age I get the following errors. Kindly advise on what has to be done. The locations of my files placed are as follows, C:\Program Files\Apache Software Foundation\Tomcat 5.5...

Regarding Usage of Servlet in my application

I have a JSP form which is made of <input type="file"/> tag alone for allowing the user to browse and select the excel sheet. Am going to write a servlet program for uploading the file that is selected to the server. My questions here are, Which method must be used in the servlet program to receiving the file and processing? Such as ...

Is each webcontainer require it's own Servlet implementation?

We usually get servlet-api.jar along with web/app server. So does it mean each one have it's own implementation of servlet JSR or will they use SUN provided api. Does this applicable to all other J2ee API's like EJB JMS MAIL Thanks, Student ...

PersistenceManager and Open Session In View

Hi, my java skills are a bit rusty and I'm wondering how I can implement Open Session In View pattern for the PersistenceManager called from a servlet in a google app engine environment. I have some singleton which handles the PersistenceManagerFactory, but how can I get a "new" PersistenceManager at each servlet call ? I want my bus...