servlets

Servlet - how to download multiples files from database

I look around and it seems that zipping all the files together is the way to go. If that the case this is the design I am thinking of doing. Please let me know if there is more efficient way of doing this Client select multiples file of downloading, then click Download servlet receive the requests, then do multiple SELECT (files are sa...

Available Servlet 3.0 implementations?

Which implementations of the Servlet 3.0 specification are available (or at least in beta) besides GlassFish? ...

Maven dependency for Servlet 3.0 API?

How can I tell Maven 2 to load the Servlet 3.0 API? I tried: <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>3.0</version> <scope>provided</scope> </dependency> I use http://repository.jboss.com/maven2/ but what repository would be correct? Addendum: It works with a depend...

CSS file is not loading?

I am having a JSP file with the below codes <HTML> <head> <link rel="stylesheet" type="text/css" href="../CSS/home.css" /> <link rel="stylesheet" type="text/css" href="../CSS/left.css" /> <script type="text/javascript" src="../js/friend_request.js"></script> </head> <body> <div class="menu"> <form name="search_form" method="p...

Send data to HTTPservlet in android

This is the servlet code in java ME. protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); ArrayList<String> listName = new ArrayList<String>(); ArrayList<Integer> listLongitude = new ArrayList<Integer>(); ArrayList<I...

Notify user about session timeout in J2EE

My requirement is to notity the use with a popup saying that the user session is about to time out in x seconds in case user does not perfrom any activity on the web page. Addition to this requirement is to decrement the value x seconds dynamically in the popup. The environment I use is J2EE. Please suggest. ...

How to implement the session compression in Java?

I was listening .Net Rocks! podcast (with Scott Hunter) where it was mentioned about session compression. I wonder how can I achieve the session compression in Java? ...

Constructor dependency injection with Servlet 3.0?

Since Servlet 3.0 it is possible to register Servlet instances programmatically with javax.servlet.ServletContext#addServlet. This class has also a createServlet method which analyses some annotations and performs dependency injection. I wonder if I need this method if I don't need the annotation processing. I'd like to have a servlet wi...

how to send through ServletOutputStream characters in UTF-8 encoding

My servlet code looks like that: response.setContentType("text/html; charset=UTF-8"); response.setCharacterEncoding("UTF-8"); ServletOutputStream out = response.getOutputStream(); out.println(...MY-UTF-8 CODE...); ... then I get the error: java.io.CharConversionException: Not an ISO 8859-1 character: ש javax.servlet.ServletOutputSt...

how to retrieve multiple selected values from <select multiple > in java code ?

code is below: <select name="merTransactionTypeId" class="cbox" multiple> <!-- <option value="0" <%=request.getParameter("merTransactionTypeId")!=null?"0".equalsIgnoreCase(request.getParameter("merTransactionTypeId"))?"selected":"":""%>>All</option> --> <option value="2" <%=request.getParameter("merTransactionTypeId")!=null?"2...

Are servlets the only way to write a Java Web Application

Hi, Are servlets the only way one can write web applications in Java ? ...

Tomcat not shutting down within Eclipse.

I'm building a relatively simple web-app where the main servlet implements the ServletContextListener interface to determine whether the context has been started or stopped. I've implemented my contextInitialized, contextDestroyed, init and destroy methods (both init and destroy call super on the base class). I've currently implemented n...

how to use the image file located in local drive, for printing it in jsp page or servlet page?

I want to display the image located in my local drive. I am using sun java app server 8. For example If I generate a file abc.jpg dynamically and store it in c:\abc.jpg, then how could I use it in jsp or servlets? How to display it in the jsp or servlet pages? I know giving the path c:\abc.jpg in coding to display image wont work , becau...

Inject dependency into static field

I want to make template engine available in servlets. The concrete template engine implementation should be changeable behind the TemplateEngine interface. With usual dependency injection it could look like this: public abstract class BaseServlet extends HttpServlet { private TemplateEngine templateEngine; public void setTempl...

is it possible to track or store the visited or clicked urls in webpages created using servlets and jsp?

I created a webpage contains more than 10 links . is it possible to store the clicked urls or visited in my database or file . I have developed webpage using servlet. It is just a page with 10 links. ...

How do I let a user know that his/her session has expired?

I have set Tomcat to dispose of sessions after 15 minutes of inactivity. Something like this <session-config> <session-timeout>15</session-timeout> </session-config> Whenever a user accesses a restricted page (one that requires a user to be logged in) I check the session to see if the login process has been completed. If it has th...

from html to servlet

hi i'm learning html and sevlets,i wrote small aplication but i'm not getting any output when i click submit button from from.html page: below is my code <html> <body> <h1 align="center>Color Selection Page</h1> <form method="POST" action="/SelectColor.do" > Select Color Charecterstics<p> Color: <select name="color" size="1"> <option>li...

classpath problem

Hi, I'm trying to compile the Servlet class in Tomcat's webappps/Email/src/Mail folder, but I'm getting compile time errors: ./Email/src/Mail/Mail.java:7: package javax.mail does not exist import javax.servlet.http.*; ./Email/src/Mail/Mail.java:9:package javax.servlet does not exist import javax.servlet.*; ./Email/src/Mail/Mail.j...

How do you return a JSON object from a Java Servlet

How do you return a JSON object form a Java servlet. Previously when doing AJAX with a servlet I have returned a string. Is there a JSON object type that needs to be used, or do you just return a String that looks like a JSON object e.g. String objectToReturn = "{ key1 = value1, key2 = value2 }"; ...

Error code mappings in web.xml not working

Hi, I have created a simple web application, for which I want all responses with 404 status code to be redirected to an error page within my web-app. I have included the following entry in my web.xml file. <error-page> <error-code>404</error-code> <location>/error.html</location> </error-page> In my main servlet, I send back...