servlets

Servlet being called twice!

Hi there, sorry but I do not have the actual code with me, but I will try to explain: I have a servlet mapped to the following: /admin/* So, this goes to a servlet: public class AdminController extends MainController { public void doPost(HttpServletRequest request, HttpServletResponse response) { // Do stuf here } ...

Querying data from Oracle database using java servlet with Netbeans.

From index.jsp code, statement.executeQuery("select * from fus where tester_num like 'hf60' ") ; Example I want "hf60" to be a variable(userinput), wherein USER must input/write data from input text then submit and get the data so that the result will be ("select * from fus where tester_num like 'userinput' "). Where should I insert th...

HTTP headers encoding/decoding in Java

A custom HTTP header is being passed to a Servlet application for authentication purposes. The header value must be able to contain accents and other non-ASCII characters, so must be in a certain encoding (ideally UTF-8). I am provided with this piece of Java code by the developers who control the authentication environment: String f...

Online exam web application

I am developing an online exam using JSP/Servlets which is nearing completion. I'm planning to add timer function for the entire exam that shows elapsed time in minutes. How do I implement this with a fool-proof technique to implement this, because using javascript would mean that the user can turn off the feature in the browser. Any hel...

Apache Commons HTTPClient 3.x leaving connections open

I'm using HttpClient to execute a PostMethod against a remote servlet and for some reason a lot of my connections are hanging open and hogging up all of my server's connections. Here's more info about the architecture GWT client calls into a GWT Service GWT service instantiates a HttpClient, creates a PostMethod and has the client execut...

Print Dialog in servlet/jsp

I want to display print dialog in servlet/jsp. Below is my code: DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE; PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet () ; PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras); PrintService defaultService = PrintServiceLookup.lookupDefaultPrintS...

java session variables

i'm hearing that some people believe storing info on the server in a session is a bad idea, that its not secure. as a result, in a multi-page business process function, the application is writing data to a db, then retrieving the info when its needed. is there something necessarily unsafe about storing private info in a session? ...

Is there a .NET analogue for Java app servers?

Are there any what in the Java community would be called "application servers" for .NET? Similar to Tomcat, Resin, and Jetty. I'm not interested in a JSP equivalent, I'm looking for a servlet-based technology for XML/HTTP transaction processing (no UI). If there is not a product like this, what would a good stack be to emulate this? Mi...

How to get user roles in a JSP / Servlet

Hi, Is there any way to get a String[] with the roles a user has in the JSP or Servlet? I know about request.isUserInRole("role1") but I also want to know all the roles of the user. I searched the servlet source and it seems this is not possible, but this seems odd to me. So... any ideas? ...

Ensuring Users are Authenticated in Java Web App

My web app has a secure area which users log in to via a JSP. The JSP posts the user name and password to a servlet, which then checks to see if the users credentials are valid. If they are valid then the user is directed to the secure resource. How can I ensure that users can't just navigate to the secure resource without validating ...

tomcat application missing displayname

I have a little project with some jsp deployed on an Tomcat 5.5. Recently the Servlets which are also deployed with the jsp files (one war archive) stopped working. I also checked out a previous version from my svn which should work. What I noticed that the displayname (I use a german version of Tomcat , so I guess that is how I would tr...

cookies vs session

Hi, I am in the training of web developement.Now i am learning jsp & servlet.I have some idea about HttpSession.I used HttpSession in some of my sample projects also.In browsers i have seen option "delete cookies".If i delete the cookies it deletes the HttpSession also. Is cookies and session are same? Can any one provide the good art...

Liferay: Initialization order of servlets and portlets

I think that it used to the be the case that in Liferay 4, if a war contained both a portlet and a servlet, the servlet was initialized before the portlet. Now with Liferay 5 I notice that the opposite is going on. How can I setup my web application, or Liferay to always have the servlets initialized before the portlets? ...

Persistent cookies from a servlet in IE

I have a cookie which is generated from a servlet and that I would like to be persistent - that is, set the cookie, close down IE, start it back up, and still be able to read the cookie. The code that I'm using is the following: HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance() .getExterna...

Starting a threadpool in a servlet container

I have a servlet S which handles callbacks from a 3rd party site. The callback invocations happen in a specific order. Thus, I need to queue them. I propose to use an in-memory queue like java.util.ConcurrentLinkedQueue So the logic looks like this: Servlet S receives a callback & queues the received item into queue Q. By this ...

How to programatically 'login' a user based on 'remember me' cookie when using j2ee container authentication?

i'm using form based authntication in my WAR. i want to implement a 'remember me' cookie so: 1) how can i intercept the authentication before user is redirected to the form? 2) say i checked the cookie and its fine, how do i actually login the user? ...

Does it make sense to use a framework for a simple java web app?

I've done lots of java web development using jsps and servlets, and I have found this approach to be straightforward and flexible. Some of the groundwork involved though - such as managing database connections - is rather tedious, and it takes a fair amount of work just to get a new web app off the ground. I'm therefore considering us...

How to know which URLs are mapped in the current servlet context in a Spring 2.0 Controller method?

In Spring 2.0, is there a quick way to have a list of the current servlet context's mapped URLs from inside a Controller method? I'm writing a method called getMappedUrls(), and the purpose of this method is to show what urls are mapped in the current servlet context. This method is to be used to generate an small online doc of availab...

How do I make Tomcat stop caching my servlet responses?

I'm learning Servlets programming, using Apache Tomcat 6 on a Ubuntu 8.10 machine, and I'm running with a very annoying issue -- apparently, related to caching. This is what I'm doing: I write a servlet, put it in a nice directory structure and deploy it using the Tomcat Web Application Manager. It works as expected. Then I edit the ser...

Java Servlet Filter Equivalent in Ruby [on Rails] and PHP ?

Not sure if the terminology is correct, but are there rough equivalents to Java Servlet Filters in Ruby and PHP ? Are they actual concrete classes ? I assume there is also a number of common web app libraries/frameworks in Python. Is there an equivalent there ? Thanks. === ADDENDUM === On the good advice of Kevin Davis, I just want t...