servlets

What are the advantages/disadvantages of the Tomcat request handling instance?

What are the advantages/disadvantages with regards to the fact that Tomcat only creates one instance of a Servlet class to handle all requests for a JSP/servlet? ...

ajax call to servlet puzzler

Greetings! I'm having a problem getting a text value of a captcha from a servlet through ajax call. When my captcha gets created, its text value is written to session, but after refreshing the image itself though ajax call, I only get one old value of the text. Refreshing the image itself works ok, but I'm stuck getting the correct v...

enable url rewriting for a 12 year old java web application

Hello, I'm trying to add the session tracking feature to a 12 year old java web application. Which uses MVC pattern with jsp and servlets. We need to make it work if cookies are disabled. I like to know what is the best way to implement session tracking to this application? :) and when i use getRequestDispatcher, do i need to use en...

How I can specify directories in war file ?

Dear all, I am new to servlet . I use the following code in servlet.then deployed to Jboss 4.1 . backup_database_configuration_location is location of properties file.But it can't be find. how I can specify directories in war file ? Thanks all in advance try { backupDatabaseConfiguration = new Properties(); FileInputStream backupDa...

J2EE -- Handling HttpSession session timouts while serving flash content

While serving flash based training material users peroidically experience a HttpSession session timeout. Currently the inactivity timeout is set to default (30mins). Questions: Would it be a good idea to attempt to increase MaxInactiveInterval for any user who is requesting a training flash video to prevent the timeouts? Would a b...

How can I prevent spring-security from appending ;jsessionid=XXX to login redirects?

When an unauthenticated client requests a URL that requires a non-anonymous access level as defined in security-config.xml, spring security sends an HTTP redirect to our login page (e.g. /login). That's fine. The issue is that absent an existing session (identified by a cookie provided in the client's request), spring-security issues a...

Accessing second servlet when grails is configured in web.xml

How can you have a grails application as well as other servlets defined in your web.xml? I want to have it so that some url patterns are handled by a servlet while all others are handled by Sitemesh/grails. The default configuration of web.xml generated by grails is: <filter-mapping> <filter-name>charEncodingFilter</filter-name> ...

Can the same servlet perform input validation from an html form it displayed?

Is it possible to have the same servlet perform validation? It seems that one might have to utilize some sort of recursion here, but when I type in something in the e-mail box and click submit the e-mail parameter is still blank. After I click submit, the URL changes to: http://localhost/servlet/EmailServlet?Email=test The page shows E...

How do I reference and export another project when developing a J2EE web app?

I have several J2EE projects using servlets, each of which extends from a base class that handles the main doGet and doPost methods and calls more specific methods on the subclasses. Rather than have that base class as a class in each WAR file, I want to move it to its own JAR that each of the other projects can reference. I'm using Ec...

Spring servlet mapping - no css or jsp!

I read over this post, which is similar to my issue, but had no luck solving the problem: Basically I used to have the following servlet-mapping in my web.xml: <servlet-mapping> <servlet-name>myServlet</servlet-name> <url-pattern>/index.html</url-pattern> <url-pattern>/channel1</url-pattern> <url-pattern>/channel2</url-pattern>...

How should I connect to a MySQL data source from Eclipse?

I have an external MySQL server that's set up and working fine. I created a database connection in Eclipse and can view the database in the Data Source Explorer tab. Now, I have a servlet that needs to access that database. How do I do it? Is there a way to reference that database connection created in the data source explorer, or do...

Write file data as Bzip2 to output of servlet response

I'm trying to get Tomcat to write out the servlet contents as a bzip2 file (Silly requirement perhaps but it's apparently necessary for some integration work). I'm using the Spring framework so this is in an AbstractController. I'm using the bzip2 library from http://www.kohsuke.org/bzip2/ I can get the contents bzipped fine but when...

how to make my files present in a tomcat server to the browser

I have installed Tomcat 5.0 in order to execute a web application. How can I show my files which are present in Tomcat to the web browser? I tried http://hostname:8080/myfolder/login.html, but I can't see the files. One more thing I know about JDBC and other database connectivity and I have developed a HTML page. How can I let a button ...

Can webapplication be notified that the web container (ex. Tomcat) is reloading, unloading or shutting down

I have a Wicket Web Application running in Tomcat. The application uses Spring (via org.springframework.web.context.ContextLoaderListener) to initialise the application. This is all well and good for start up, but what I would also like is to receive some sort of notification that the Context is being destroyed so that I can shutdown spa...

Design question - Persistent data in a webapp session

Hi, I am developing a web app using servlets and jsps. I have a question about storing data I need to use across multiple servlets in a login session. When the user logs in, for example, I get the user object from the db and would like to store it somewhere and have the subsequent servlets and jsps use it without having to query the db ...

how to link the servlets from the html file

I do have the home html file, when I give the context root http://localhost:8080/ccc the html file automatically loaded in browser. In the html file I have five links, each contains the , link in this format, <a href="servlet_alias_name">Title</a> , when I click on the any one of the link, it says servlet_name not found...is it not poss...

httpservletrequest - create new session / change session Id

I'm maintaining a Java web application. Looking into the login code it gets an HttpSession out of HttpServletRequest via the getSession() method of HttpServletRequest. (It uses some values in the session for authentication purposes) However I'm worried about session fixation attacks so after I have used the initial session I want to ei...

"Unable to Load Servlet Class in specified module" shown while adding servlet to war file

I'm using sun java app server 8.0 PE, I have created webapplication and added some servlets and deployed successful. after some time I again, tried to add someother servlet as a webcomponent, while adding I got following error , what is problem exactly? "Unable to load servlet calss specified in module, java.lang.ClassNotFoun...

How to implement Affiliate Links to my web application?

I have built a web application using Java EE platform that sells one of my software. Now I want to give the work of marketing my website to various e-marketing companies. But as I will have to give the commission to them, I should know that who sends the traffic. I think that one solution to above problem is: Make a separate URL for e...

What is the difference between ServletRequest's getRemoteHost() and getServerName()

The javadoc is a bit confusing to me, and in my local tests it seems like they both return the same thing. What am I missing here? ...