servlets

Why Servlet is unavailable after 3rd deployment in jboss 4.2.0

I am working in a struts-hibernate application. I have seen a error on 3rd time deployment of application in jboss4.2.0. When i deployed it for first time, it runs. Even in 2nd time deployment, it works. But, in 3rd time deployment, it shows an error "Servlet is unavailable". Why it fails in 3rd time? ...

Problem in Context Listener

I was trying to run a servlet using ServletContextListener ,I've put the codes from the book "Head-First" writter "Kathy sierra", but this is not working.Its shows 404 error.I have put the class files in the directory C:\Tomcat 5.5\webapps\Listener_exe\web-inf\classes\com\example. and web.xml file in web-inf directory. So please show whe...

Session Id Management in Servlets

Hi. I am having some issues with my web application while doing a performance test with Jmeter. My question is not around Jmeter instead, it's around a simple Servlet session management behavior. So we have a web application, where in when you request a login page, it passes back a "Session Id" in response headers and that is used for ...

Accessing Tomcat Internals from Servlet (or Filter)

I would like to get access to the Tomcat internal data from a servlet (or filter). In particular, I would like to read information about busy threads, from thread pool manager. So, my question is if it is possible at all (I can imagine that it could be blocked for safety reason)? If it's possible, maybe someone could give me any advice w...

@WebServlet annotation support in java 1.6.013

Hi, I'm stepping into the world of Servlets and 3.0 in particular and I saw certain methods and annotations used in examples and tutorials which talked about this being available when JAVA 6.0 is released (which it has) and now when I try to use the above annotation for example in Eclipse it does not recognize it although I have java 1.6...

JavaBean Introspection in Servlets [Tomcat]

What is the equivalent "servlet code" for this: <jsp:useBean id="user" class="beans.UserBean" scope="session"/> <jsp:setProperty name="user" property="*"/> Tomcat translates this to: beans.UserBean user = null; synchronized (session) { user = (beans.UserBean) _jspx_page_context.getAttribute("user", PageContext.SESSION_SCOPE); ...

How to create a thread that runs all the time my application is running

EDIT: I'm now sure that the problem is related to the while (true) loop holding all other commands as I've commented it out and the application deploys without the attached exception. I'm not sure how much it is important but my ServletContextListener implementation looks like this: public class BidPushService implements ...

Injecting an object into a HttpSessionAttributeListener via Guice ?

Configuration: Guice 1.0, Apache Tomcat 6.0 I am currently manually injecting objects configured in a Guice Module, into my servlet, using this method: public void init( ServletConfig config ) throws ServletException { super.init( config ); ServletContext sc = config.getServletContext(); Injector injector = (Injector) sc ...

Access user session objects from another thread, how to make it?

How can I access a user session objects from another thread? I want to delete some users on a regular basis. I can just delete them from the database, but some user can be logged in. So I want to invalidate his session if its exists. How can I find and invalidate his session using his userId? As I understand a servlet container has som...

JSP:Servlet:How do I set session timeout of greater than 30 minutes

Dose anybody know how to set session timeout greater than 30 minutes? these two methods wont work (default to 30 min). <session-config> <session-timeout>60</session-timeout> </session-config> and session.setMaxInactiveInterval(600); Thanks. ...

Why does ServletContext#getRealPath("/") return a relative path?

I have the following snippet of code: String path = servletContext.getRealPath("/"); Now I got a bugreport from a user saying that the returned path is not an absolute path. The returned path is 'usr/local/...' instead of '/usr/local/...' , so getRealPath seems to be returning a relative path. I can see this, because the returned pat...

How to send parameters from a servlet

Hello, I am trying to use a RequestDispatcher to send parameters from a servlet. Here is my servlet code: protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String station = request.getParameter("station"); String insDate = request.getParameter("insDate"); ...

ZIP on the fly immediatelly

I need to generate a ZIP file with data on the fly from a servlet. I pass the ServletOutputSream to the ZipOutputStream constructor, and it does and send the ZIP to the client correctly. When the ZIP result is large, the servlet takes to answer a lot. I suppose that first creates the ZIP and after send it. I make a helper class that w...

Displaying a result of a query from the database in increments

I want to display a list of all the users in my site but I only want to display 10 people per age. I don't know how exactly to do this. I know how to do it by just displaying all the users in one page but that's not very good is it? If I do it with the code I have now, it will only get the first ten users over and over again. I want t...

ServletContext.getRequestDispatcher() vs ServletRequest.getRequestDispatcher()

why getRequestDispatcher(String path) of the ServletRequest interface cannot extend outside the current servlet context where as getRequestDispatcher(String path) of the ServletContext can use the getContext(String uripath) method to obtain RequestDispatcher for resources in foreign contexts. and how?? Please...

How to specify Http Request timeout parameter on Java servlet container

Hi, I'm trying to understand where I can configure a request timeout for all requests arriving to a servlet of mine (or all of my servlets)? Is that, as I think, a container property? Also, how does this affect different browsers? Do they all comply to the parameter the container dictates? Or maybe the request timeout time isn't even so...

microsoft technology similar to j2ee servlets?

I have a java application which runs under Tomcat. Fairly simple architecture - users invoke a servlet through HTTP which then puts a request onto an in memory queue. A consumer thread which was started as a ServletListener and is running continuously polls the queue and processes the requests which includes calling some stored procs a...

using GWT RPC mechanism with my customized Servlet

I currently have a GWT application which uses the RequestBuilde to send messages to a servlet I have (using POST and GET), and my servlet (in doPost and doGet) "pauses" the request (this is done by using Servlets 3.0 spec) and adds it to a queue. Additionally I have a Daemon thread which runs in the background and "plays" the request...

Does closing a BufferedOutputStream also close the underlying OutputStream?

I am streaming binary data (a CSV file extracted from the database as a Clob) to the browser by calling response.getOutputStream() and would normally wrap the OutputStream in a BufferedOutputStream when copying the data. Should I close the BufferedOutputStream or will this also close the underlying OutputStream? [Extra question: Do I n...

Shutting down an ExecutorService

In Tomcat, I wrote a ServletContextListener which will start an ExecutorService during startup and terminate it when it is unloaded. I am following the example in the javadoc for ExecutorService public void contextDestroyed( ServletContextEvent sce ) { executor.shutdown(); try { executor.awaitTermination( 50, TimeUn...