servlets

how to check if a sessionId is valid in a servlet (java)

I am maintaining a map of sessionid(s) and HttpSession Objects in my web app. I use an HttpSessionListener to populate or remove a session from the map. When my web server crashes and goes down and comes back up, i need a way to check if the sessionid being submitted is valid or not. Obviously, when the app comes back online, the Map is...

Streaming a pdf through a servlet to a browser

I have yer typical servlet that streams a pdf to a browser. The pdfs are stored on an internal server from which my servlet fetches. If I hit the servlet directly from the browser, the pdf is displayed. If I try the same URL in an <IMG> tag in a web page, ... broken pipe. Any insight on why this should be? As an experiment, I can s...

Using a Servlet for a non-servlet application

I know 'normal' Java, but am new to the world of servlets, containers etc. Because of that I am not sure which approach is most sensible. Situation: I have created a Servlet that receives information and stores it in a database. This database gets read by other applications. Now what I need is an application that receives the exact sam...

Want to set Jetty to hot deploy, but there is no deployer

I'm running a SmartFox 1.6 server with included Jetty servlet container. I want to configure Jetty to automatically deploy new web apps. Normally this is as simple as adding a scanInterval to the deployer: <Call name="addLifeCycle"> <Arg> <New class="org.mortbay.jetty.deployer.ContextDeployer"> <Set name="contexts"><Ref id="...

Lightweight & Fast REST Server library for java?

Hi, I'm looking for a lightweight REST library. It must be small (in kb size) & Fast (In total execution time). The optimal solution is a single jar without any dependencies what so ever. The application is designed to run on the AppEngine so the library should work on GAE/J platform. Thanks for the helping, Maxim. ...

jsp refers to an PDF streaming servlet - security question

Somewhere behind our firewall sits a server full of PDFs. The PDFs contain private information so I need to restrict access to the PDFs. The public can log in to our web site and request their PDFs. Our software went to production recently. We're redirecting them to the PDF server's URL. This fails because the public can't access ou...

Setting both error message and body from servlet

I want to write a servlet that will return an http response like so: HTTP/1.1 500 <short custom message> Content-Length: ... <longer custom message> The reason is that I want a programmatic client to be able to process the response message to take a particular response but I also want to fill in the response body with a longer explan...

can't access servlet, 404 not found

edit 10/8/10 @ 8:20am est - since I can't make this work in prod, I'll try to make it fail in test. edit 10/8/10 @ 4:30pm est - having a great time!!! NOT. Ok, hell continues. I learned earlier today that we're also running Apache httpd as a separate process. So we're thinking maybe we're not forwarding the request to Tomcat somehow....

using servlets in a struts 2 project

I am building an application using struts2. The web.xml file looks like below <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*...

Stream video to Windows Media Player over http

Hi Trying to stream video to windows media player from a servlet (progressive download style). The streaming works, but I have some weird behavior, which I would like to rule out is not caused by a problem in my implementation. When using WMP to open an url from the servlet, WMP will perform a total of 4 http-get requests for the same ...

Differences between a HttpURLConnection and a browser connection

I'm trying to connect to a web page through a HttpURLConnection but it's not responding the same as a regular browser (firefox, chrome). I'm getting an error 500. With the same code I can get "anyother" page (google, for example). My code is posted below, but I'm pretty sure it is ok. Using "Live HTTP Headers" firefox addon I sent the...

What is the lifecycle of a HttpServlet?

Hi all, Basically, how long is an instance of a servlet around for? I am kind of guessing it is session scope. However, I suppose it could have some sort of timeout or garbage collection to remove old instances. Thanks, Grae ...

Why isn't my Java HttpServlet able to find my cookie's value?

I've created two servlets: UserReceiverServlet receives a username from a form. It then sets the username to an attribute and forwards the request to UserDisplayServlet. UserDisplayServlet will add the username to a cookie and then display the current continents of both the attribute which was set and the cookie which was stored. How...

Why use the HttpServletResponseWrapper vs extending HttpServletResponse directly

I'm looking at the decorator HttpServletResponseWrapper and I'm wondering what is the benefit in using this wrapper vs simply extending HttpServletResponse and overriding what you need? What is the benefit in having this intermediary wrapper which just delegates all its methods? thx ...

How do I implement a dummy filter to exclude a file from being filtered?

Hi, I am trying to implement a filter for all my files excluding login.jsp. I understand that filter mapping cannot exclude certain files. What I need to do is to create another filter to map just the login.jsp. How do I create another file that with url pattern /login.jsp and without SessionFilter being processed after it? Here is part ...

Spring MVC application context path

Hi all. My Spring MVC application is runnning on a Tomcat behind an Apache 2 acting as a proxy. I access my app directly in tomcat via an url like http://localhost:8080/myapp. I access my app via proxy with an url like http://localhost/tomcat/myapp. The second url makes my app behave incorrectly, because it supposes it lives in /myapp...

Simulate a multiple file upload with one file

Hi to all I have a sample code using Jakarta HttpClient that uploads a file to a web server. What i want is to simulate a multiple file upload of the same file with different name for each upload. Is this possible? Any hints? A.K. ...

FileUpload problem with Struts on server

I am trying to create a upload servlet that handles enctype="multipart/form-data" from a form. The file I am trying to upload is a zip. However, I can upload and read the file on localhost, but when I upload to the server, I get a "File not found" error when I want to upload a file. Is this due to the Struts framework that I am using? Th...

How to read manifest.mf from POJO class (not a servlet) instantiated by spring?

I have a simple service called BuildNumberService which would be instantiated by spring. I'm trying to find the cleanest code for the class to find out the MANIFEST.MF file from the jar file it has been packaged into. The code has to run inside a servlet container. @Service public class BuildNumberService { private static final S...

Struts1.x and tiles1.1 problem

Hi folks, I am trying to integrate struts 1.x with tiles 1.1 but I am facing problems! Here's snippet of struts-config.xml: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd"&gt; <struts-...