servlets

Custom WEB MVC for a leagacy JEE project

Hi all, I am in the middle of creating my own custom MVC web framework for a project.This project has very old code base where one JSP page directly submits a form to another JSP whereas the paths are also hardcoded. Now it is a big project and putting Struts or JSF will take considerable amount of time. So my suggestion is to build a sm...

Why there are no constructor in servlet?

Hi I am studying servlets I read that servlets are java programs but there are no constructor in servlet... Can anybody elaborate on it? ...

Using a java class to create a database

Hi, I'm working in an application that uses servlets and mysql. I'd like to create a .jar file able to create the database that the application will be using. This will only be done once, in order to create the db. I've no problem in getting to access to a database, doing something like this: Class.forName("com.mysql.jdbc.Driver").ne...

Lazy Intantiation of the Spring MVC DispatcherServlet?

Is there a way for me to instantiate the Spring MVC DispatcherServlet in code rather put it in the web.xml and have it be instantiated by the web server? The reason for this is that I want to check a memCache to see if I have already recently rendered the page that is being requested and if so just return from the memCache, rather than ...

What are implicit objects ?What does it mean?

Whenever I study JSP and Servlets I come across word implicit objects, what does the term mean? How they are called in my program without instantiating objects? Who instantiates implicit objects? Please elaborate? Thanks ...

how do I find out what open sessions jboss is handling at any given moment with java?

I need to write a servlet that, when called, gets information about the current instance of jboss it is running in, specifically, a list of the currently opened sessions. is there a way to do this? thanks in advance. ...

Are JSP and Servlet container same?

I like to know JSP and Servlet container are same? Which are they? Is only one container responsible for calling Service methods of both? Than why do we call Jsp container and Servlet container? ...

Best way to protect url so that only defined party can interact each other

I have jsp/struts application need to upgrade. Currently we only have 1 websystem(branch) and now I need to upgrade and build another websystem that represent HQ. HQ and branches are different domain. HQ can see 4 branches in the HQ page. We need to login to access HQ and branches. If HQ want to see the details in branch A, we can click...

initialize ServletContext using a method on a Resin server

Is there a way to initialize the ServletContext for a webapp on a Resin server using a method? I need something like that runs once, when the server starts up. ...

Manage database connection using connection pool or session. How?

I have a simple task to accomplish, but I am not sure what is the best way to go by. Each user has their own username and password to connect to a database with different privilege. Once the user connect, he will do multiple query base on what action he want to perform. Therefore I want to retain the connection with the database. So h...

How do web.xml filters work? Can you have two filters map to all pages (/*) and specify the order?

I want to use Spring Security, and it says to map the filter to /*. But I already have a filter mapped to /*, which is the Tuckee URLRewrite filter. Is it possible to map two filters to the same thing, and also is there a way to specify the order that the filters get called? ...

java.lang.IllegalStateException: Cannot forward after response has been committed

int noOfRows = Integer.parseInt(request.getParameter("noOfRows")); String chkboxVal = ""; // String FormatId=null; Vector vRow = new Vector(); Vector vRow1 = new Vector(); String GroupId = ""; String GroupDesc = ""; for (int i = 0; i < noOfRows; i++) { if ((request.getParameter("chk_select" + i)) =...

Browser treating real file differently than servlet-generated file

I have an application that uses html5 to let the user listen to some audio samples on the server. If I specify the path to an actual audio file on the server, things work as expected: <audio src="/audio/english/banana_1.mp3" controls> Your browser does not support the <code>audio</code> element. </audio> However, if I point to a ...

Client side sessions

I want the clients of several related web apps to hold their own authentication state. This improves scalability, because no session replication between cluster nodes is needed. And it makes integration of different server technologies like Java Servlets and PHP easier. My plan is as follows: Set a signed and encrypted cookie with th...

how to append a list in href url?

Hi All, I want to append a list in the url that is a href ,how can do so and how can i read it using request.getParameter() ? or a complete bean object in the url ? ...

how to handle concurrency in java servlets

Hello , In my doPost method of the servlet I need to access a file (shared resource ) and update the file . How do I cater to some 100 users using this at the same time ? Regards, Mithun ...

Parse large XML files over a network

I did some quick searching on the site and couldn't seem to find the answer I was looking for so that being said, what are some best practices for passing large xml files across a network. My thoughts on the matter are to stream chunks across the network in manageable segments, however I am looking for other approaches and best practice...

My java web server works in eclipse but it crashes every time if ran through the command line

I have a VERY simple web server that does accepts client connections, retrieves static web pages and services servlets. I wrote the web server in Java and I'm using the tomcat library for servlets. I tested all my code by running it in the eclipse IDE and everything works fine, but when I run my code through the command line it starts ...

Error when assigning value to a Double in Java Servlet

Hi, I was debugging an error I was getting with a java servlet. I was assigning a value to a Double in the class, however occasionally when I ran the servlet I was getting a random number as the value. Not sure if this has to do with using the wrapper versus primitive? Here is a snippet of code: public class MyClass extends Http...

Session is lost and created as new in every servlet request

I have this big issue. My current session is gone every time I made a new request to Server. I have checked in a lot of places. I can't find what's the problem. I also have included session-config in web.xml both in tomcat and application. I also enabled to accept cookies to my browsers. Tested in every browser. It's not working. I am...