servlets

Jetty Servlet does not run -- getting directory listing instead

I'm trying to get a servlet built and running in Netbeans to run on a jetty server. Deploying locally always works, however deploying on Jetty results in a directory listing rather than the servlet actually running. The problem seems to be with the context configuration, but I have no idea what I'm doing wrong. Here is the XML for web...

Throwing an exception from a ServletContextListener

I want to throw a ServletContext exception from a method in a class which implements ServletContextLister. Here is my implementation which is failing: public class Initializer implements ServletContextListener { private void checkEncryptedFile() throws ServletException { FileReader fr; try { fr = new FileReader("TestFile"); ...

Ajax Requests again

hi, I have again a problem with my ajax requests. my architecture hasn't change, so I use a Java servlet on the server side, and on the client I'm running a JavaScript application, programmed and tested with firefox. In firefox I also installed firebug, because it's very comfortable to watch the incoming and outgoing ajax requests. howe...

java script problem.

Question level : Intermediate / Beginer I created a form with `method="post" action="eh.do" onsubmit="return Form1_Validator(this)"` The validation is successful and works fine when i hit submit. But on the servlet, i have a concatenate function to merge the values together. When the java script is turned on, ie when i write o...

How many actions should a servlet perform?

Hi, I'm new to web development and am just wondering about best practices for java servlets. Should each servlet perform exactly one action, ie a servlet for login, a servlet for registration etc, or should I look to combine similar actions by passing a different parameter to tell the servlet which action to perform? Cheers ...

Lightweight servlet engine for serving java application via IIS

I have an old legacy java web application that I want to deploy on the same server as my asp.net-applications (running on IIS 7). And I need to have all applications running on port 80, so I can't just install two web servers on different ports. The java-application is really simple, just a couple of serverlets (no JSP) with functional...

Configuring Spring based servlet with sysadmin defined properties

I have a web application that's based on Spring and the application contexts, applicationContext.xml and myServlet-servlet.xml contain settings that should be configurable by the sysadmin in deployment. What's the best way to enable changing of settings like [database server details, remote webservice endpoints, etc] without requiring e...

jsf-facelets forward bypass servlet filters

For one week, i am playing with appfuse-jsf-basic but i noticed something. If i do not put tag to my navigation rules, i can view a page that require ROLE_ADMIN with ROLE_USER rights. Then i understand something that facelets doesnt use "servlet.forward" methods for forwarding so filters does not catch facelets forwards in navigation ru...

use flash capture webcam image?

Is there any open source flash utility that i can embed on a webpage and use it to capture user webcam image or short duration clips and do "POST" to my server servlet ? i do not looking for streaming video and so i do not need red5 or flash server. can you folks elaborate ...? ...

Can I intercept and change the request url of a HTTPServletRequest within a Java Servlet filter?

Hi there. I have a Java web application which manages data for many clubs. I would like the application to show club information depending on the URL that is typed in. Eg. If you enter "localhost:8080/MyApp/Club1" ...then the app should strip out the end of the requst url (Club1), do a lookup in the database for the club, and add this t...

Alternative for JavaScript onUnload

Hi, there is an alternative to the Javascript onUnload? I use JSP Jakarta Struts framework with a Servlets. I must know, when is window closing, because not everyone clicks on Logout button. How do you handle it in your applications? ...

servlet for implementing socket connection

How do I implement a web application with a Servlet that is listening on a port for socket connections? ...

Java thread start() without join() or interrupt() in servlet

I have a servlet filter that carries some logic and produces output before a request is served by it's primary page. I have a new need to send out the output a few seconds later than at the moment it is generated (with ~10s delay). Because of certain poor design choices made earlier I can't move the position of the filter just to have th...

Committed before 401 No authentication specified

I'm programming using GWT, which includes Jetty. I have defined my own servlet and when I call response.sendError(HttpServletResponse.SC_UNAUTHORIZED, e.getMessage()); It gives me a warning that states: WARNING: Committed before 401 No authentication specified Sep 2, 2009 2:40:36 AM com.google.apphosting.utils.jetty.JettyLogger warn ...

Java URL - Passing Arguments - Servlets

Currently using the HTTPServletRequest class and specifically the .getQueryString method to retrieve an inputted URL. The URL it will parse is say server/package/servlet?args1/args2/arg3.. I'd like to remove the question mark (?) from the URL however I have no idea how you would accomplish this. I'd just like to replace it with a forw...

how to add the servlet api to my pom.xml

How do I add the servlets API to my project's pom.xml mvnrepository.com has lots of servlet api and similarly named projects, that I don't know which is the right one. Or are all of them ok? ...

Fastest way to copy text from a File to a HttpServletResponse

Hi, I need a very fast way to copy text from a file to the body of a HttpServletResponse. Actually I'm copying byte by byte in a loop, from a bufferedReader to the response.getWriter() but I believe there must be a faster and more straightforward way of doing it. Thanks! ...

HttpServletRequest and getHeader(): How to handle case insensive headers properly?

Hi! Since is made aware of the fact that HTTP headers are case-insensive according to the RFC, i wonder how to handle this problem with Servlets. There is a #getHeader(String) method to obtain a header but it turned out that this method treats the header fields case sensive which is quite... annoying? Is there a proper way to obtain ...

Read resource inside context (.war) from a jar file

I am using JBoss4.0.1 and Struts2.1.6 I have an application which have some configuration file(appConfig.xml in folder WEB-INF/config). This congiuration file contains the relative paths of other files to be read.(other.xml, some.xml etc). Application is deployed as .war inside default/deploy I have a Utility package that reads the con...

Init method invocation in filter

Could anyone please tell me why the following line about filter init method invocation is incorrect: The init method on a filter is called the first time a servlet mapped to that filter is invoked. ...