servlets

File.lastModified() returns stale date on Google App Engine

So recently I learned that in order to serve static files with a Last-Modified header from Google App Engine, I had to write my own (simple) servlet to do that. OK fine, I went and did it, results can be viewed here. But now I find that File.lastModified() is always returning the same value, no matter that I have touched the file, even...

Servlet control multiple request.

When i click a link im calling a servlet. When i click that link multiple time the servlet throws an error (error details not important) Though there are other work around for this fix (Like disable the link once clicked, etc) I am curious is there any way to control this thru request/response Object. ...

Handling Character Encoding in URI on Tomcat

On the web site I am trying to help with, user can type in an URL in the browser, like following Chinese characters, http://localhost:8080?a=测试 On server, we get GET /a=%E6%B5%8B%E8%AF%95 HTTP/1.1 As you can see, it's UTF-8 encoded, then URL encoded. We can handle this correctly by setting encoding to UTF-8 in Tomcat. However...

Internal Server Error

I am getting an unusual error while running my application, just wondering if anyone has come across this before. I am using google protocol buffers, my servlet takes a request and tries to process it, I have the following code: InputStream s = request.getInputStream(); AdRequest adRequest = AdRequest.parseFrom(s); After executing th...

How to display ipv6 address on a web page?

I'd like to display an IPv6 address on a web page, as done on http://ipv6.whatismyv6.com/ What's the best way to do this? A code sample would be most awesome. ...

Making servlet serve READONLY text/html resource

While i am serving text/html resource resource i want to make it the resource as readonly. And we need to restrict editing the readonly attribute who is downloading the resource ...

Difference in deploy and redeploy

Hello, Could anyone please tell me, what the meaning of the word "Deploy" and "Redeploy" in context of Tomcat in the following line: ServletConfig parameters won't change for as long as this servlet is deployed an running. To change them, you'll have to redeploy the servlet Thanks very much in advance. ...

Change FileServlet root path

I use Resin webserevr. There is great FileServlet class for serving static content. I'd like to remap URIs like /user1/file.txt -> /users/dir1/1/file.txt /user2/file.txt -> /users/dir2/22/file.txt ... in runtime. But username->path mapping is not static and based on some database data. ...

Why not SingleThreadModel synchronizing the attributes?

Hi, I'm a little confused by the following paragraph: "The effect of implementing SingleThreadModel is virtually the same as synchronizing the service method. Both can bring a web app to its knees without protecting the session and context state." As STM synchronizes the service method, so isn't it quite obvious that it'll also synchr...

How to obtain an HttpSession Object from SessionID?

I want to invalidate sessions of users based on some Event. I store their sessionID, how to get their HttpSession from this ID? The HttpSessionContext class is deprecated with no replacement. ...

Access denied to resource file from java servlet

I am trying to access a resource file from a servlet but getting HTTP Error 500 - access denied: File file = new File("//warChildFolder//myFile.txt"); InputStream is = new FileInputStream(file); // <--error on this line I am on google-app-engine. Any help appreciated! ...

Is it possible to retrieve the form name from a Java HTTPServletRequest?

I would like to get the name of the form used to post parameters from a Java HTTPServletRequest object. Is this possible. I don't see any method that looks like it will return it to me. ...

What's a good FOSS java servlet session replication solution

I work on a very high volume public website running on Tomcat 5.5. Currently we require stickiness to a particular server in order to maintain session. I'd like to start replicating session, but have had trouble finding a good FOSS solution. I've written my own Manager (using memcached as the store) but am having trouble dealing with ...

Dynamically generate JFreeChart in servlet

I'm trying to generate graphs dynamically using JFreeChart as a result of some checkboxes the user selects, but I can't figure out how best to get the generated datasets into chart form (I have code that makes charts from these, but need to produce pngs) and into the JSP view. Currently, I can only think of sending the Datasets to the J...

Merging 1000 PDF thru iText throws java.lang.OutOfMemoryError: Java heap space

I am trying to merge 1000 PDF Files thru iText. I am not sure where the memory leakage is happening. Below is the sample code. Note that i am removing the child-pdf file as soon as i merge to the parent file. Please pointout bug in below code or is there any better way to do this with out memory conception. This process is done thru serv...

Advantages and Disadvantages of J2EE vs. Servlets

What are the primary reasons for using the J2EE (EJB's) over just a simple servlet implementation? I am working on developing a new project that will primarily be a web service that must be very fast and scalable. Sorry for any confusion, Although I am experienced in Java, I am very new to the Java Web world, and may not be asking thi...

Obtain search engine query-string from a servlet

Hi all, I want to improve my site usability by providing users some kind of "related search" funcionality if they are coming from a search engine. It is possible, from a servlet, to obtain if a visitor of my site is coming from search engine results page? If yes, is possible to obtain the query string? Thanks in advance EDIT: Thanks...

Google Docs PDF Streaming is faster than java servlet Stream?

I am trying to serve PDF (useing tomcat server + Servlet normal streaming). The steaming is stable there is no bug and it handling parallel serving. But not as fast as Google DOC PDF Streaming. My Question is how did they do that fast ? What server they use (Apache + PHP)? or Python? Please suggest which technology i can use to speed ...

where is the best place to start learning about servlet/tomcat?

I need to start developing using this technology servlets/jsp with tomcat. I need to get up to speed fairly quick. What would you recommend to get up there fairly quick? No 900+ pages manuals. A good tutorial (even a video lectures) with lots of examples would be perfect. Thanks ...

Running linux process from servlet useing Runtime.exec()

Is it good idea to run linux process in multi user environment. Ex: Runtime rt = Runtime.getRuntime(); Process proc = rt.exec("linux command"); int exitVal = proc.waitFor(); // may wait till 5 to 10 mins ...