servlets

Cannot configure datasource for db2 in tc-server.

I am getting a null pointer exception when trying to set up datasource in spring's tc server. Which is basically a Tomcat at its core. Here is the exception I am getting. org.apache.naming.NamingContext lookup WARNING: Unexpected exception resolving reference java.lang.NullPointerException at java.util.Hashtable.put(Hashtable.java:394)...

java.io.IOException: Server returned HTTP response code: 500 for URL: https://hostname:port/xxx.do

We are getting the "java.io.IOException: Server returned HTTP response code: 500 for URL" error for the following code which is for applet-servlet communication. The same code has been working for long and now suddenly we see this error. Could something be wrong with tomcat setup? Tomcat logs do not show any error. The exception is throw...

Session replication, how does a container suppose to work?

I would be interested in some timing details. FOr example I place in session some container, whcih can keep different data. I do change of content of the container frequently. How can I assure that the container session value get replicates across nodes for any change? ...

I am confused about servlet instance in web app

I am reading Head First Servlets & JSP and I am very confused about servletcontext. The book says there is one servletcontext per web app and have a picture with many servlets in web app but in entire web app should have only one servlet and have a thread for handling many request, right? Why do they have many servlets in a web app? A...

Servlet session invalidate

Hello All: I have 2 apps in 2 different servers - Tomcat(basically a .WAR file) and a EAR in jBoss. EAR is a reusable app where I will authenticate the user and send back the control to the app on the Tomcat. While authenticating I am creating a session object on the jBoss app. When I send back the control to the app on Tomcat I will...

Using JSP to download a file

I am currently trying to use JSP to build some small litle apps and have not got stuck on something, downloading files from a webserver. I just cant seem to work out how I should go about this task. Are there any JSP developers here who know to go about this and could point me in the right direction? ...

Why is creating Servlets in Eclipse breaking my web.xml?

Being somewhat lazy, I was rather happy to find that I could create a new servlet source code by going New -> Servlet, instead of going New -> Class and then editing the class into a servlet. However, I have discovered that every time I create a new servlet in Eclipse, Eclipse modifies my web.xml. Specifically, it modifies the top elem...

Why is my Java JOX parser servlet failing to convert from bean to string?

Currently working through a tutorial on JOX included within Sams Teach Yourself JavaServer Pages 2.0 with Apache Tomcat in 24 Hours Either the com.wutka.jox has changed or the author missed a crucial ingredient. When I try to execute: java "hu/flux/xml/XMLTestClient" "http://localhost:8080/SamsTeachYourselfJSP/joxparse" "d:\education\...

How to chain JSP response to Servlet request

I have a situation where I have to generate a lot of HTML and then return it as a string JSONP style. So the eventual HTTP response will actually be javascript text like this: myglobaljavascriptcallbackfunction('<HTML here>'); Since the HTML is complex, the only sane way to construct it is with a JSP. So what I would like to do is take...

Close jsp using Servlet

Hi, My requirement is on clicking a button in a jsp page, it should call another jsp page and that jsp page should get some details and revert back to the first jsp page. I tried calling another jsp page using the following code : window.showModalDialog('stopwarn.jsp', 'dialogHeight:500px; dialogWidth:500px', '') Both jsp pa...

is the Java Servlet I've created in Netbeans adding something strange?

Hi, This is my second try to solve this problem. My first try was here but perhaps my explanation of my problem was insufficient, my problem was that the applet received the exception: java.io.StreamCorruptedException: invalid stream header: 0A0A0A3C at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:783) at java....

JSON and HTTP POST through URL

Hi, How can I allow my servlet to accept 4 parameters via HTTP POST through a URL? Example of URL: http:///servlet The information returned will be in text format using the JSON format. JSONObject myStr = new JSONObject(); Am using Model-View-Controller access model. JSP are my view pages, Servlets are my controllers and model are...

Efficient cache synchronization

Consider this public Object doGet() { return getResource(); } private Object getResource() { synchronized (lock) { if (cachedResourceIsStale()) { downloadNewVersionOfResource(); } } return resource; } Assuming that doGet will be executed concurrently, and a lot at that, and that downloadin...

Passing parameters through URLs

I've written a servlet which queries a database for a list of messages, the output is directed to servlet generated html. The user has the option of selecting to view a selected message by clicking a button ResultSet rs = null; try { startPage(response); rs = statement.executeQuery(sql); while(rs.next()) { ...

JSON, Servlet, JSP

Hi, Firstly, my HTTP POST through a URL accepts 4 parameters. (Param1, Param2, Param3, Param4). Can I pass the parameters from the database? Once the URL is entered, the information returned will be in text format using JSON format. The JSON will return either {"Status" : "Yes"} or {"Status" : "No"} How shall I do this in servlet...

How to download a file using GWT client ?

What is the best way to download a pdf file using GWT client ? Should I invoke a normal servlet to do that ? or is there a different preferred approach to handle this problem ? I am new to GWT, so if some sample code would be of great help. Thanks Deep ...

Why session.invalidate doesn't work in IE browser ?

I implemented a sevlet filter in my application, and within the filter, if I find some specific url pattern, I will use request.getSession().invalidate() to logout and clear the session, then redirect to a login page. session.invalidate(); session.setAttribute("hi", true); response.sendRedirect("login.jsp"); but I found, after that I ...

Remove server name from JSESSIONID

Hi, Our application runs on JBOSS and its front end on Apache. When accessign the URL externally, the JSESSIONID displays the servername within the Content property of the cookie. Any ideas how this can be removed??? Thanks, ...

JSP login with declarative security - How does the actual authentication happen?

Hi, I've been a little puzzled with this as I have not seen many examples that gave me the complete picture. The best explanation I found so far is this. By defining a security role in web.xml such as "admin" for example, and having my login form with all the necessary fields (i.e j_security_check as action, and fields j_username, j_pa...

Prefered way to handle Java exceptions in ServletContextListener

Hi, For servlet lifecycle stuff, what do you guys recommend doing in response to an exception... For example, public class Foo implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent event) { try { // something nasty } catch (Exception e) { throw ...