servlets

Tomcat reporting IncompatibleClassChangeError - classpath problem?

I'm trying to deploy an application to Tomcat 7 on a Windows server. I have a local copy set up and have tested with Eclipse without any trouble, but on the production server I get IncompatibleClassChangeError messages. This had been a problem on the local server when there were problems with the classpath, but I configured the correct...

Java: how to verify image file on localhost exists

This is driving me bonkers. I'm writing a web app in Java and all I want to do is verify the existence of an image that's saved to an /images folder right under the web root. The 1,000,000 google searches I did seemed to indicate that the File.exists(path) method is the way to go. But for obvious reasons, I don't want to hard code the p...

How come request.getPathInfo() in service method returns null?

I wrote Front Controller Pattern and ran the test. Somehow request.getPathInfo() is returning null when it should return the path info. 1. HTML that calls servlet <a href="tmp.do">Test link to invoke cool servlet</a> 2. Map the servlet in DD. Anything that has .do extension (ex tmp.do) will invoke the servlet "Redirector" <!-- SERVL...

What is recommended way for spawning threads from a servlet in Tomcat

Probably a repeat! I am using Tomcat as my server and want to know what is best way to spawn threads in the servlet with deterministic outcomes. I am running some long running updates from a servlet action and would like for the request to complete and the updates to happen in the background. Instead of adding a messaging middleware like...

How to access the session from a Java class

I need to write a small Java class that will enable me to add to and read from the current user session. Everything I see refers to Servlets but I'd ideally like to just use a plain old class. Can anyone please help this Java Newbie? Thanks ...

How do I list files in web folder of a different java web application

I need to list files under a folder of a different web application. Is there a way to get this done without having to provide the actual path in a properties file? Webapps - WebApp1 -MyFolderOfInterest - WebApp2 - WEB-INF - Classes - MyClasstoListFiles TIA ...

From within a servlet how do you access a variable set inside a corresponding servlet filter?

I'd like to use the following filter to open and close persistence managers. public final class PersistenceFilter implements Filter { private static final PersistenceManagerFactory persistenceManagerFactory = JDOHelper.getPersistenceManagerFactory("transactions-optional"); private static PersistenceManagerFactory factor...

Can a servlet open a socket to talk to native code?

I have a C API that talks to hardware and I want to ultimately make calls to that API from a browser. Thinking some to the c++ servlet lib's are too complicated, as is JNI, I thought I could prove the concept like this: A java servlet gets a simple string message via HTTP. The servlet opens a socket to pass along data via UDP. C process...

FacesContext and "Servlet" Context

Hi, is there any equivalent to FacesContext, but in servlet environment? I have some DAOSessionManager that handles transaction to my database. I can use the FacesContext to identify the current http request when the current page is written using JSF, but what about servlet ones ? I can't find any way to get the current Servlet conte...

JSP 2 and Servlet 2.4 broke my custom tags

Hello experts, We recently switched to Servlet 2.4 and JSP 2 on a project and our custom tags no longer work. We have tags like: <myTags:someTag value="${x}" /> and once in the tag we evaluated x bean and went from there. Now the evaluation happens directly in the JSP and we get a String (apparently x.toString()) set for the value at...

Possible to send an image to my Servlet as a ByteBuffer?

I am attempting to have my android phone connect to my servlet and send it a certain image. The way I figured I would do this, is to use the copyPixelsToBuffer() function and then attempt to send this to the servlet through some output stream(similar to how I would do it in a normal stand alone java application). Will this way work? If s...

Java Servlet getParameter for a param that is a URL

I am building a site which submits a url to a servlet for analysis purposes. On the client side, I submit the url as a parameter that is encoded. For example... Submit: http://www.site.com Goes to: http://localhost/myservlet/?url=http%3A%2F%2Fwww.site.com On the server side, I have my servlet request the parameter like so... String u...

javax.servlet.jsp.JspTagException: 'begin' < 0

javax.servlet.jsp.JspTagException: 'begin' < 0 Once in a while you run into an error and you say: What the WHAT?? tagexception begin < 0. Seen this wonder before?? ...

how to send an email from jsp/servlet?

how to send an email from jsp/servlet? ...

Maven Test on servlet receiving an IllegalStatException: Cannot reset buffer - response already committed

During the test phase of my maven build I ave the following code in one @test method: request.clearAttributes(); response.reset(); String story_uuid = qit.getQI().getStory_uuid(); assertNotNull(story); request.setParameter("story_uuid", story_uuid); request.setParameter("activity", "ge...

What is the best practice to deploy database config (username/password) with Java web-app (web.xml)?

I have a Java web-app using standard web.xml and servlets. At the moment, I'm using the <context-param> tags in web.xml to define the database configuration (JDBC url, username, password, etc.). These are picked up by a servlet in its init() method. But I'd like to not include database username/password in my source repository. For t...

How to read context-param values from web.xml with a normal Java class

I know it it is easy to read the context-param values from web.xml with a Servlet. But is it possible to read the value with a normal java class? ...

Making two android emulators talk through a servlet

I am trying to create a tic - tac - toe type of game where two androids can play with each other. I am trying to build this game using eclipse SDK and a servlet written in PHP (or I can use Java if needed). The diagram is attached ( http://www.scorechase.com/tictactoe.PNG ) which depicts one side of the data flow. Here is the problem 1]...

Custom header not inserted in request in servlet

There's a thrird party app that needs to get information via custom http headers, so I wrote a simple test app that creates this headers and then redirects to a page that lists all headers. The header-generating servlet snippet is: protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, I...

Suggestions for implementing method invocations based on the parameter passed to servlet

Hi, I would like to get some suggestions on implementing a solution that invokes ejb methods based on the parameters I pass to a servlet. I have a web project and an ejb 3.0 project. The ejbs are invoked from the servlet in the web project. The ejbs are invoked based on the parameters I pass to the servlet. For every action I need to ...