servlets

Is there a way to optimize the way I generate a file and output it as .zip in a java servlet?

A user has a few Lookup selections on a JSP page. After he's selected what data he wants exported, the JSP calls my servlet which should do something like this: get request data generate SQL for the request data execute the SQL and write it to a XML file package the XML file to a ZIP file and return it as a response Now, the first tw...

The best place to store large data retrieved by a java servlet (Tomcat)

I have the java servlet that retrieves data from a mysql database. In order to minimize roundtrips to the database, it is retrieved only once in init() method, and is placed to a HashMap<> (i.e. cached in memory). For now, this HashMap is a member of the servlet class. I need not only store this data but also update some values (counte...

Problem while donwloading excel sheet from servlet response

I am trying to download an excel sheet from servlet response. When I click on link which sends request to server for returning an excel sheet, save/save as dialog box gets opened asking to save the excel sheet. This is an expected behavior. But in between, if I try to use IE 6 or below version, then it opens up new window after clickin...

JBoss AS 5.1: Overriding context parameters when deploying a Servlet webapp

Is there any way to OVERRIDE a webapp's context parameters (already defined inside its WEB-INF/web.xml with default values) when the webapp.WAR is being deployed to the JBoss AS 5.1? Apache Tomcat has a nice feature whereby if a webapp WAR file is being deployed using the Tomcat Manager, you have the option of supplying an XML configura...

How do I logout from Java EE container managed security?

I am working in websphere 7.0. I use the security from the application server. I would like to removing the association with the user, so user is redirected to the login page before accessing a secure resource (and request.getUserPrincipal() returns null). I try : request.getSession().invalidate(); but the user principal is still ...

Startup Servlet for WAR File

Hi, I am deploying a .WAR file on Tomcat v5.5. I want to run a thread on the startup of the war file. So I am thinking of using Startup Servlet for this. But I don't have much knowledge about servlets/startup servlets. Can you guys guide me a bit on how to do it? Any descriptive links on this issues will also be much appreciated. :) ...

Django debug toolbar template listing feature for Struts2

I'm developing a Struts2 application that uses Sitemesh as template engine. What I need is a list of all the templates (JSP) that are used by request. In other projects I use Django Framework, with it I've this amazing Debug Toolbar that, besides many other useful info, provides me with the list of templates the request used for display...

Using AbstractExcelView from a portlet

Hi Experts, how can i use spring AbstractExcelView to generate a excel file in a portlet Thanks Sam ...

unable to connect to server (error-404)

I created a sample Dynamic Web Project in Eclipse, but when I am running my project with Tomcat 5.5 i am getting this error: HTTP Status 404 - /greetingservlet/ type Status report message /greetingservlet/ description The requested resource (/greetingservlet/) is not available. My HTML/JSP source code is: <!DOCTYPE greeti...

Infinite loop when using filter for jsp files

When I make filter for all jsp pages, the browser goes into an infinite loop, but when I make filter for only one page, it runs correctly!! Here is doFilter method, if some one find the error plx tell me... public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletExce...

Using some beans in Filter bean class ?

Hi all, In my filter bean class, I added some beans dependancy (with @Autowired annotation). But in the method doFilter(), all my dependancy beans have null ... public class FacebookOAuth implements Filter { @Autowired private BusinessLogger logger; @Autowired private IUserSessionInfo userSessionInfo; @Autowired private FacebookOAuth...

http status 404

Possible Duplicate: unable to connect to server (error-404) still i am getting same error even after modifying it. my new servlet: import java.io.*; import javax.servlet.*; /** * Servlet implementation class Greetingservlt */ public class Greetingservlt extends GenericServlet { /** * */ private static f...

Spring Security, Spring MVC and Login Sessions

I have my Spring MVC & Spring Security up and running as suggested by Spring's own reference application "petclinic". Everything's fine except that the login does not persist a browser restart. What has to be considered to make sure a logged in user does not need to relogin after browser restart? ...

In spring MVC, where to start and end counter to test for speed execution time?

I want to know how long it takes a particular page to render, where are the various parts in the Spring MVC framework that I can start and stop my timer? BTW, what java class should I use to get the most accurate time in milliseconds? ...

How to create a session object?

I am creating a login page for my web application. I want to create a session object whenever a new user logged in. I know the concept of sessions, but i didnt used that before. Can i do it with a simple class. Or, i have to move to servlet. If i shall do it with a simple class means, how to create a session object. This is my scenari...

Create concurrent HashMap in webapp

What is the best way to make threadsafe HashMap in Tomcat ?I'm going to create ConcurrentHashMap on InitServlet once on load on my application. (<load-on-startup>1</load-on-startup>) Requests from different threads will read and write data to my ConcurrentHashMap. I'm not good in mutlithreading, so not sure is it approach correct? A...

OAuth, Sessions, Servlets

I'm trying to implement OAuth for a Twitter app with Servlets/JSPs but I have a question. Since I have to redirect the user to the Twitter authorization site and pull request parameters from the callback, how do I exactly keep all this in one session? My assumption is that when I redirect/forward the user to the new site that's gonna b...

Java EE + GlassFish: Force user to logout if he/she log in somewhere else

I hope my question on the title make sense, if not, let say: machine A, via the web browser I log in as admin, I go to machine B, and log in as admin, the web browser in machine A should force a logout on user admin. I gave this some thought, and I think it will be ugly if I try to manual implement this. I have a feeling that this can be...

Servlets - Browser can't access css, images when doing a forward to a JSP?

I'm having trouble with loading css and images when I have a servlet forward to a JSP. Specifically, when I set my welcome-file to index.jsp, the css is being loaded and my images are being displayed. However, if I set my welcome-file to HomeServlet and forward control to index.jsp, the css is not being applied and my images are not bein...

OAuth Callback Session

I'm having a problem figuring out to maintain the same session after I get the oauth callback in a servlet. Since th callback come from Twitter and not the clients browser, I get a different session. Can someone help?? ...