servlets

How to build a WebAppDescriptor with a filter class and servlet class?

I'm working on setting up a Jersey test suite for a servlet and a servlet filter that I want to test behavior of the combination of the two for. What I'm confused is how the Jersey documentation states how to build WebAppDescriptor using the WebAppDescriptor.Builder class, specifically between the servletClass() and the filterClass() me...

How to bind a servlet to a context?

I got javax.servlet.ServletException: Error instantiating servlet class servlets.MemoServlet javax.naming.NameNotFoundException: Name servlets.MemoServlet is not bound in this Context when using <form action="MemoServlet"> I know I could use managedbeans, but I've to use servlets. I suspect the problem has to do with JSF. context...

why we can't initialize a servlet using constructor itself?

Why do we have to override init() method in Servlets while we can do the initialization in the constructor and have web container call the constructor passing ServletConfig reference to servlet while calling constructor? Ofcourse container has to use reflection for this but container has to use reflection anyway to call a simple no-arg ...

Java getQueryString() doesnt return hash value to me

I am using java ee and request.getQueryString() doesnt return the #hashpart my/page?id=4#hash I am using Struts 2 Is there any solution? ...

Send error message as JSON object

I have two servlet: first servlet is similar to a client and creates an HttpURLConnection to call the second servlet. I would like send a special error, formatted like a JSON object, so I call sendError method in this way: response.sendError(code, "{json-object}") But in the first servlet when I read error with getResponseMessage me...

SIP servlets, chatserver

I'm trying to get a SIP servlet chat server working, together with the textclient found here. When I use 2 clients to send messages to eachother (peer to peer), everything goes well. But when I use one or more clients together with my server, I have to wait exactly 32 seconds before the server picks up any new messages in the doMessage(...

Servlet receiving data both in ISO-8859-1 and UTF-8. How to URL-decode?

I've a web application (well, in fact is just a servlet) which receives data from 3 different sources: Source A is a HTML document written in UTF-8, and sends the data via <form method="get">. Source B is written in ISO-8859-1, and sends the data via <form method="get">, too. Source C is written in ISO-8859-1, and sends the data via <a...

Error in my web.xml

Why i have an error in my web.xml when i want add servlet..? <servlet> <servlet-name>ClientServlet</servlet-name> <servlet-class>org.task.ClientServlet</servlet-class> <servlet-name>FactoryServlet</servlet-name> <servlet-class>org.task.FactoryServlet</servlet-class> <servlet-name>TraderServlet</servlet-name> <...

Questions about serving static files from a servlet

I'm very new to servlets. I'd like to serve some static files, some css and some javascript. Here's what I got so far: In web.xml: <servlet> <description></description> <display-name>StaticServlet</display-name> <servlet-name>StaticServlet</servlet-name> <servlet-class>StaticServlet</servlet-class> </servlet> <servlet-m...

make difference between 2 buttons

Hi, In my JSP i have 2 buttons submit one for updating and the other is for deleting from database. I put i button like the following: <td><img src="ok.jpg" onclick="MettreAjourForm();" name="ok"/></td> and in the same servlet i want to make difference in the treatement of the 2 cases. Is there any proposition? Thanks. ...

Can't get InputStream read to block...

I would like the input stream read to block instead of reading end of stream (-1). Is there a way to configure the stream to do this? Here's my Servlet code: PrintWriter out = response.getWriter(); BufferedReader in = request.getReader(); try { String line; int loop = 0; while (loop < 20) { ...

Hibernate entities stored as HttpSession attribute values

I'm dealing with a legacy Java application with a large, fairly messy codebase. There's a fairly standard 'User' object that gets stored in the HttpSession between requests, so the servlets do stuff like this at the top: HttpSession session = request.getSession(true); User user = (User)session.getAttribute("User"); The old user authe...

How to use GWT when downloading Files with a Servlet?

Hello Guys I am creating a simple project that will allow me to upload and download files using gwt. i am having trouble with the downloading of files that are on my server. For the file upload i used http://code.google.com/p/gwtupload/ and followed the instructions there. My file is stored on the server outside of the website contai...

JSP How to scale an image?

Is there anyway to scale an image then display in jsp page? When retrieve and display the images, I want to show all photos in same size. is there any API can do it? I have searched from google, those I found was about scaling images byusing tookit but can't works in web application. ...

task strategies for handling HardDeadlineExceededError

I've got a number of tasks/servlets that are hitting the HardDeadlineExceededError which is leaving everything hanging in an 'still executing' state. The work being done can easily exceed the 29 second threshold. I try to catch the DeadlineExceededException and base Exception in order to save the exit state but neither of these excep...

Read quicktime movie from servlet in a webpage?

Hi, I have a servlet that construct response to a media file request by reading the file from server: File uploadFile = new File("C:\\TEMP\\movie.mov"); FileInputStream in = new FileInputStream(uploadFile); Then write that stream to the response stream. My question is how do I play the media file in the webpage using embed or obje...

Is there a max size for POST parameter content?

I'm troubleshooting a java app where XML is sent between two systems using HTTP POST and a servlet. I suspect that the problem is that the XML is growing way to big. Is it possible that this is the problem? Is there a limit? When it doesn't work, the request.getParameter("message") on the consumer side will return null. Both apps are r...

Java JSP/Servlet: controller servlet throwing the famous stack overflow

I've read several docs and I don't get it: I know I'm doing something wrong but I don't understand what. I've got a website that is entirely dynamically generated: there's hardly any static content at all. So, trying to understand JSP/Servlet, I've written my own "front controller" intercepting every single query, it looks like this: ...

Importing a class in a JSP file

I wrote some code as a Java Servlet and I am now trying to convert it to a JSP. I wrote a class in a separate file which I was using, and I can't figure out how to get the JSP file to recognize the class. I guess it has something to do with importing. I gave the class a package (package mypackagename;) name and I tried using <%@ page imp...

calling a java class in a servlet

hi, in my servlet i called an instance of a class.java( a class that construct an html table) in order to create this table in my jsp. the servlet is like the following: String report=request.getParameter("selrep"); String datev=request.getParameter("datepicker"); String op=request.getParameter("operator"); String batch =request.getPar...