servlets

Accessing a ColdFusion datasource from Java code

I have a servlet that I would like to run within ColdFusion MX 7. I would like to make use of an existing ColdFusion DSN as a javax.sql.DataSource, if possible. I thought something like coldfusion.server.ServiceFactory.getDataSourceService().getDatasource(dsname); would work, but unfortunately the servlet returns java.lang.NoClassD...

How to count open db connections ?

I'm developing a web app using Java servlet to access Mysql db, how can I get the number of connections to my DB that is currently open ? Edit : I tried "show processlist", it showed me : 2695159, but that's not right, I'm just developing this new project, I'm the only user, couldn't have that many processes running, what I want is the...

How to test a webapplication?

If I have java-webapp (servlets), what is the best way to create automated tests for this application? Should I start a server? But that is very fragile. Should I call the servlets directly? But how can this be done? I don't know how to create a ServletResponse/ServletRequest. And what is the best way to test the functionality of the w...

One or multiple servlets per webapp?

I know, it depends on the webapp. But in the normal case, what do you do: one servlet, that serves different pages (like an standalone-application with changing content) or for every page a single servlet. Take for instance a blog. There is the start-page with the most recent blog-entries, an article-view for displaying one blog-entry a...

What is the best way to allow both a servlet and client-side scripts read the same file?

We want to share user validation configuration between a Java validation class (for sanity checking) and a Javascript-enabled form web interface (for usability). What's the best way to deploy this static file in our web application so that it is both available to the server-side code, and available via a URL accessed by the client? So f...

AccessControlException when attempting to delete a file

We have a java web service application that uses log4j to do logging. An exception gets thrown when log4j tries to delete its rolling log files Exception:java.security.AccessControlException: access denied (java.io.FilePermission /var/opt/SUNWappserver/domains/domain1/ applications/j2ee-modules/ourwebservice/WEB-INF/logs/IMWrapper.log....

Access Get parameter with a scriptlet

I hava a url such as search.do?offset=20 offset sometimes is in the url sometimes not. When it is not in the URL i want it to be 0. i try, without success, to retrieve the value with a scriptlet as follows: <% Integer offset = (pageContext.findAttribute("offset")==null) ? new Integer("0") : new Integer((String) pageContext.findAttri...

How Can I put information in a outputstream from tapestry5 ?

How Can I put information in a outputstream from tapestry5 ? I need a page when a user enters it open a dialog for save or open the file with the outputstream information. I write the next code: public class Index { @Inject private RequestGlobals requestGlobals; @OnEvent("activate") public void onActivate() { try { HttpS...

Disable JSP extension processing

I have a JavaEE 1.4 web application running on WebSphere Application Server 6.0. In web.xml, there is a servlet configured to intercept all server requests: <servlet-mapping> <servlet-name>name</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> This works fine until I try to request something ending with *.jsp. In this ...

Jquery how to get attribute from a HttpServletRequest

Hello all: I have this piece of code: $("#faq").click(function () { var url = $.get("faq", { pagina: "page" }); alert(url); }); On "faq" responds to a Servlet that sets an attribute on the request .... request.setAttribute("pageFAQ", pageFAQ); .... After the get jqeury prints [object XmlHttpRequest]. I would lik...

Strip Images, CSS and JS from servlet-mapping

I am using the following servlet-mapping in my web.xml file: <servlet> <servlet-name>PostController</servlet-name> <servlet-class>com.webcodei.controller.PostController</servlet-class> </servlet> <servlet-mapping> <servlet-name>PostController</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> To do some ki...

tomcat 5.5 - problem with reading resource files

I'm using Tomcat 5.5 as my servlet container. My web application deploys via .jar and has some resource files (textual files with strings and configuration parameters) located under its WEB-INF directory. Tomcat 5.5 runs on ubuntu linux. The resource file is read with a file reader: fr = new FileReader("messages.properties"); The proble...

Java Servlet : How to detect browser closing ?

In my web app, when a user logs in, I add his Id to a vector of valid Ids in the servlet, when he logs out, I remove his Id from the vector, so I can see how many current users are active, if a user forgets to log out, my servelt generated html has : <meta http-equiv="Refresh" content="30; url=My_Servlet?User_Action=logout&User_Id=1111...

Can I implement HttpSessionListener this way ?

I'm trying to tracking valid user Ids in my Java servlet, can I implement HttpSessionListener this way ? public class my_Servlet extends HttpServlet implements HttpSessionListener { String User_Id; static Vector<String> Valid_User_Id_Vector=new Vector<String>(); private static int activeSessions=0; public void sessionCreated(Ht...

Tomcat VS Jetty

I'm wondering about the downsides of each servers in respect to a production environement. Did anyone have big problems with one of the features? Performance, etc. I also quicky took a look at the new Glassfish, does it match up the simple servlet containers (it seems to have a good management interface at least)? ...

Servlet containers and class path

To what is the class path of a servlet container set to? As per my understanding there are three components involved. The jars in the lib folder of the servlet container and then the classes in the WEB-INF/classes and jars in the WEB-INF/lib folder. The classes in lib folder of the servlet container are added to the system class path a...

How to close EnityManager when not injected?

I have a servlet running in an Oracle OCCAS server. Currently I map some data in a database to an entity class in my application using @Entity annotaion. I fail to inject the EntityManager (@PersistenceContext) though, and to my understanding that is because it is running in my servlet context and not as a separate Entity EJB. Creating t...

countdown timer in JSP/Servlets

Hi, I am developing an online examination using servlets/jsp.I need to add a count down (hh/mm/ss) timer to the questions page that would end the exam and redirects to results page. I am done with all the other functionalities except the timer one. Can someone provide some help on this. Thanks ...

Initialising Java Web App

I have a simple web app, with a few jsp pages, servlets and pojo's. I want to initialise the connection pool before any requests are made. What is the best way to do this? Can it be done when the app is first deployed or do you have to wait till the first request comes in? ...

threadlocal variables in a servlet

Are the threadlocals variables global to all the requests made to the servlet that owns the variables? I am using resin for the server. Thanks for awnser. I think I can make my self more clear. The specific Case: I want to: initialize a static variable when the request starts the execution. be able to query the value of the vari...