servlets

Configure web.xml (Tomct 5) for one servlet to handle all incoming requests?

Basically I want one servlet to handle all incoming request regardless of the path. I'm on shared hosting environment with access to configure my own web.xml file. I have the following configured in web.xml, but it doesn't work on Tomcat 5: <?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.4" xmlns="http:/...

Why does HttpServlet throw an IOException?

I get why an HttpServlet would throw ServletException, but why IOException? What was the reasoning behind this? ...

What does the servlet <load-on-startup> value of 0 (zero) signify

Hi, I am getting a bit confused here. In our application we are having a few servlets defined. Here is the excerpt from the web.xml for one of the servlets: <servlet> <servlet-name>AxisServlet</servlet-name> <display-name>Apache-Axis Servlet</display-name> <servlet-class>com.cisco.framework.axis2.http.FrameworkServl...

How To Read Context Parameters From a Restlet?

When using Restlets, how can I read configuration parameters passed in through web.xml? With servlets, context-param can be used. How do I read context parameters from within a Restlet? ...

HEAD GET decoded requests

Hi, We run a service on jboss. Sometimes we receive requests that have params completely decoded. Below is the apache access log entries. Look at the redirect_url params in following urls. For such urls to work the params need to be encoded. Urls that we post are encoded. Either somebody is explictly decoding stuff before it reaches us,...

What HTML templating options are there in Java as an alternative to doing HTML output from your servlet code?

Given the following Hello World servlet, how could you transfer the Hello World output out of the servlet code and put it in some kind of HTML templating format? I would like to simply call the template from the servlet and have it render the Java variables I refer to in the template - perhaps by referring to the "Hello World" string as ...

file listener process on tomcat

Hi, I need a very simple process that listens on a directory and does some operation when a new file is created on that directory. I guess I need a thread pool that does that. This is very easy to implement using the spring framework, which I normally use but I can't use it now. I can only use tomcat, How can I implement it? what is ...

How to implement openID using openid4java in GSP

How to build openID ReturnURL in gsp?? Define a ReturnURL This is the endpoint where your webapp will receive and process the authentication responses from the OpenID Provider. String _returnURL = "http://example.com/openid"; Reference:http://code.google.com/p/openid4java/wiki/QuickStart ...

Is there an Updatepanel control (like ASp.net) in java

Hi, Im basically a .net developer, I am now working on a java web project, here i need to basically get values from the back end (say generating a random number) and update that random number every second on the front end, i want to use jquery for this, in ASP.net, i know that I can have an updatepanel and use _doPostBack to update th...

Java Servlet connecting to SQL Server tutorial?

Can anyone recommend a tutorial on how to write a Java Servlet which connects to MS SQL server and manages data? I'm trying to write something which pulls products out of one database and inserts them into a stored procedure located on another database. Thanks in advance. ...

Which is better JETTY COMET implementation or Resin COMET implementation

We've been using JETTY's suspended servlet implementation to roll our own COMET web applications using JSON messages and XStream. Does anyone have experience with Resin's implementation of COMET and how they compare? Also more generically than COMET does anyone have suggestions on the best Java Suspended servlet 3.0 implementation. H...

Java application object... where is it stored?

I'm thinking about using the java application object to implement a simple cache, to save a few configuration variables, and a couple of xml with often used info... I'd like to know where is the application data phisically stored (a system file, in memory, db), how can it be configured, and if there's any kind of limitation, like space,...

How to create a servlet to return a database query in a certain div

I need to create a very simple application: I need to have a form that submits data to a servlet The servlet then queries a database to retrieve a list of reports based on the criteria given by the form The returned list of documents has to displayed in a div on a .jsp page I am not sure about the last one (number 3). I know how to c...

tutorial on using flash or java servlet to upload microphone data from browser to server?

There was a question on how to get data from a microphone on a client to a server via an HTTP browser, and the answer was "use flash or maybe a java servlet applet". Fine, but how? Is there any sample code or tutorial out there? Can it be done with a vanilla server or do I need adobe media server? ...

What is the best way to create a Java Servlet or JSP that optionally includes content depending on URL parameters

I want to create a JSP page or servlet that will work in 2 ways. A user visits their own profile page: http//something.com/profile/ Or they visit their friends page: http://something.com/profile/FriendsName They could also visit their own page through an explicit URL like: http://something.com/profile/YourName I have a servlet-mapp...

java servlets : passing url variable values with spaces

I'm building a simple java Servlet which passes categories using a URL variable into another Servlet. For example, in the following code ResultSet rs = qw.DBquery("select distinct manufacturer from Products order by manufacturer asc"); try { while (rs.next()) { table+= "<tr><td><a href=\"getItems?manufacturer=" ...

Printing from servlet, why does this not work

I want to print from a servlet. I believe I have the correct syntax. But I get the message "delete these tokens" in Eclipse. PrintWriter out = response.getWriter(); out.println("<html><head><title>Woohoo</title></head><body>\n" + "<form id="report_form" name="report_form" method="post" action="AgReportServlet">\n"+ "<table bo...

When is it ok to throw a ServletException from a Servlet?

I have been throwing ServletExceptions in the past, when something/anything goes wrong in a Servlet, mostly just wrapping the exception in the ServletException. Now I am thinking it is actually better to not throw a ServletException, but to respond with response.sendError(sc) and use the correct HTTP status codes. if I can't send an e...

How do I properly Log4j, closing all Appenders and, therefore, files

My servlet-based web-app sometimes fails to close Log4j log files when redeployed, leaking to file descriptor leakage and occassionally leading to servlet-contained dying from 'too many open files'. I have a ContextListener, what should I put into its contextDestroyed() to tell log4j to shut down and release all resources? Quick skim o...

how to get a client's MAC address from HttpServlet?

Hi I was asked to write a servlet that collects client's details such as ip, mac address etc. getting his IP is pretty straight-forward (request.getRemoteAddr()) but I dont find an elegant way to get his MAC address. seems reasonable that the web server has access to data such as Mac address etc, since it gets the TCP packets and all....