servlets

Servlet mapping in apache tomcat 6.0.20

Im not sure that its possible to do what I want to accomplish. I want to map one single servlet to two different URL. I want both http://10.0.0.1/a and http://10.0.0.1/b to map to the same servlet. I know its possibe to do the following in web.xml; <servlet-mapping> <servlet-name>ServletName</servlet-name> <url-pattern>/b</...

Java Servlet: pass a request back to default processing.

Hi there, I want a Servlet to handle requests to files depending on prefix and extension, e.g. prefix_*.xml Since mapping on beginning AND end of request path is not possible, I have mapped all .xml requests to my Servlet. The question now is: how can I drop out of my servlet for XML files not starting with "prefix", so that the reques...

How to create a zip file in Java

I have a dynamic text file that picks content from a database according to the user's query. I have to write this content into a text file and zip it in a folder in a servlet. How should I do this? ...

does openid4j work for google openid?

have anyone tried this, create openid4j servlet and try authenticate with google openid? i tried it and fail and so want to get confirmation from you all. i able to authenticate with yahoo_email and myopenid.com ...

I need to upload Open Flash Chart 2 image to servlet

How can I upload image with JavaScript from Open Flash Chart 2 to servlet? What I have to implement so that I can save that image to my server ? ...

Setting character encoding with request parameter

Is it possible to pass a request param containing the encoding to a filter which checks if there is a value and sets it as character encoding? I have read that calling the method to setting the character encoding should be done before reading the request params. Is there maybe another way to do this? Edit: Java / Java Server Pages ...

How can you serve a dynamically generated file w/ Tomcat & Java technology?

Having a hard time figuring out how to send dynamic data to a web-app's user without having to create a file & using a dynamic link to static content using java technology. (The main reasons for avoiding the file creation on disk are security and speed) This is something I have previously done in python, but this web-app is intended to ...

Write Multiple Full HTML 'Files' to Single Output Stream?

I'm writing a testing utility- I want to show multiple finished HTML "pages" in a single browser window. Is this possible? I'm using Java Servlets. For example, normally the user goes to a utility screen, fills in a bunch of fields and POSTS this to my servlet, which builds up a full HTML stream based on their input and writes it to Ht...

What is the simplest way to display httpServletResponse.sendError(403, "My Message") status from JSTL

I have a servlet which does some error checking and if something is wrong I will typically do this: response.sendError(403, "My message") return; I don't want to throw an exception from the servlet - because I would like to conform with HTTP status codes. In the web.xml I have configured the following: <error-page> <er...

Java: String representation of just the host, scheme, possibly port from servlet request

I work with different servers and configurations. What is the best java code approach for getting the scheme://host:[port if it is not port 80]. Here is some code I have used, but don't know if this is the best approach. (this is pseudo code) HttpServletRequest == request String serverName = request.getServerName().toLowerCase(); Str...

Tomcat configuration for servlets

Hi, I´ve installed Tomcat and I've been testing it: I wrote some .html and .jsp files and tried then in the server. They semm to work correctly together. For example: these files I'm trying allow me to upload a file to the server and writes its name in a database (mysql). Once this is done I have a button that allows me to upload another...

Is it hard to convert a web app built with Jsp, Servlets & mySQL to one with Spring & Hibernate?

I'm currently working on building a java web app. I've been looking to use Spring and Hibernate so I get some proper exposure to them, but I'm just getting burned out reading and learning about them. If I go ahead and build it with JSP and Servlets on a MySQL back end, what kind of levels of code reuse would I be looking at? I imagine th...

Simple tag not able to intrepret session scope attribute

Hi, I'm trying to display an attribute value of ArrayList from JSP set in session scope in servlet as: hs.setAttribute("Attr",arr); //where hs is reference to HttpSession and arr is of type of ArrayList But when I invoked simple tag with the EL expression as optionList attribute value of advice tag in JSP as: <%@ taglib prefix="c" ...

Java Servlets: why is PrintWriter.flush() not flushing?

I am currently writing a Comet application which requires me to send chunks of data at a time on a persistent connection. However, I'm having trouble flushing the message to the client before closing the connection. Is there any reason the PrintWriter.flush() method is not behaving like I think it should? This is my Tomcat Comet imple...

i got the url value using request.getHeader("Referer"), How to get the parameter values?

I need to split out parameters given a URL string. I got the url value using request.getHeader("Referer") e.g.: string rr=request.getHeader("Referer"); <%= rr %> i got the url as http://www.sun.com/questions?uid=21&amp;value=gg Now I stored that url in as string how do I get the value parameter value as uid=21 and value=gg Please r...

Getting the JSP URI that was sent to the GET/POST of a Servlet

Is there a way to get the URI of a JSP that sent a particular GET/POST request to a Servlet? I know of the request.getRequestURI() function within a Servlet, but that is just returning the URI of the Servlet itself. For example: Let's say that index.jsp sent the request to the Servlet SampleServlet. I want to get the URI of the ind...

Problem with GWT App can't get HTTP Response back from Servlet on another server

I have Application written with GWT 1.7. I have one page where I upload file to the remote server that is on different domain. So, when I do Post to the server files goes to the server but when it's time to get response I'm getting null in following function: Servlet: ... resp.setStatus(HttpServletResponse.SC_CREATED); resp.getWriter()...

java servlet: generate zip file from BLOBs

I'm trying to zip a large number of pdf files (stored as BLOBs in the DB) and then return the zip as an attachment to the user. What's the best way to do this without running into memory issues? Another note: I actually need to merge some PDFs prior to adding them to the ZipOutputStream. Therefore, a couple PDFs will need to be store...

Servlets and Tomcat

Hi, I'm working on an application. I have a servlet (writeDataBase.class) that writes some information in a database. This is working fine. My folder structure looks like: webapps/HelloWord/web-inf/classes. In folder 'classes' is where the file writeDataBase.class is placed. web.xml looks like: <servlet> <servlet-name>HelloWord</serv...

How do I package multiple WAR files in one Maven project?

I am writing an application that integrates Geoserver with a custom component, intended to be hosted on a single servlet engine. Both are Maven based projects, and I would like to stay in Maven land to package it all into a nice distributable. The general idea I have is to add another module to my application that packages the applicatio...