servlets

What does my Servlet have that my JSP is missing?

I am currently working my way through a Sam's Teach Yourself JSP. In one chapter, we wrote a crude shopping cart application which used Servlets for various functions. Come Chapter 14, we replace most of those servlets with JSP using beans. For some reason that is eluding me, my JSP isn't working. Here is the functional servlet: ...

How to make custom 404 page be a forward, not a redirect in Tomcat

I've got a Spring MVC app served in Tomcat. When the user enters a page that isn't found, it displays my default 404 page, as set in web.xml <error-page> <error-code>404</error-code> <location>/errors/404/</location> </error-page> The problem is that if the user goes to http://mydomain/bad/url it is redirected to http://mydoma...

Multiple Tomcat Instance that runs as a service

I have an existing Tomcat Installation that is running on production mode right now. It runs as a windows service. What I want is to add another tomcat instance but points to a different port but they both resides in the same Server Machine. Can this be done without having to shutdown the other instance. I browse the web and I see som...

Easy way to write servlet that returns table data in xml format

Easy way to write servlet that returns table data in xml format - ? Data comes from a database table. ...

java connection problem with mysql

I want to connect my java web application with the mysql database but whenever I am running the program it is throwing the following error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) ...

jsp does not open up

hello, i have an application where the android device sends data to a server. the server receives the data, processes it and has to open a jsp page. could some one please help. i have used the usual RequestDispatcher rd = request.getRequestDispatcher(request.getContextPath()+"/main.jsp"); rd.forward(request, response); Al...

maintaining persistent http connection

My android app sends data to a servlet every 10 seconds. the servlet receives the very first request and responds back. but the servlet doesn't receive the second set of data that the client sends after the next 10 seconds. could some one please tel me how do i go about doing this. is it something related to session? ...

Java servlet how to disable caching of page

How to disable caching ? What headers should doGet set? Could you provide a code snippet? ...

How to detect dynamically if the app is under local/online environment

greetings all i want to detect dynamically if the application is under local environment (development) or online server environment, through the httpservletRequest maybe , i don't know, any ideas ? ...

java servlet serving a file over HTTP connection

I have the following code(Server is Tomcat/Linux). // Send the local file over the current HTTP connection FileInputStream fin = new FileInputStream(sendFile); int readBlockSize; int totalBytes=0; while ((readBlockSize=fin.available())>0) { byte[] buffer = new byte[readBlockSize]; ...

Tomcat 7 session cookie path

Hi guys, I'm having a huge problem with my application and Tomcat 7. My application needs to set session cookie to "/" path instead of "/context" path. In tomcat 6 it was a matter of adding another property to Connector (emptySessionPath="true") and Tomcat 7 doesn't recognize this thing. I know that Servlet 3.0 spec allows to configure ...

Jsp include, forwarding request parameter

In my jsp file I am pulling data from the request via request.getAttribute(). Inside this jsp I need to include another jsp. Will this inluded jsp have access to the request, or do I need to somehow forward on the data? ...

Filtering static content Jersey

Hi, I'm trying to serve static content (a HTML form that calls a Jersey REST resource) from the same webapp as the servlet that handles the requests to the resource. As I understand I can filter requests to static content away from the Jersey servlet. My web.xml is as follows, but at the moment I am unable to access the static content n...

Hibernate timeout problem with servlets

I have a Tomcat servlet that incorporates hibernate. It works fine normally. When the servlet starts I initialize hibernate and create a session factory. I then use this session factory to generate sessions when performing various database transactions. So far so good. My problem comes after a long period of inactivity on the s...

ajax + servlet country state city list

I am trying to populate city, country and statelist using ajax, and servlets. Now I know how to get the XMLhttpRequest object. there is a standard mechanism to do that and depending on the cross browser compatibility, you do get a ActiveX or a xml object.. Then you send a request to the actionservlet, using xmlhttprequest.open() and you...

Jquery: post data to a jsp method?

I am currently a asp.net guy, but have to do some jsp work now. I know that in asp.net, you can define a public static method with [WebMethod] attribute e.g. [WebMethod] public static string GetIt(string code) { return GetSomething(code); } then, I can call this mehtod in jquery $.ajax({ type: "POST", url: "PageName.a...

Dynamic Web Module option in Eclipse

Hi, Could someone please explain the purpose of this option and what exactly it is for. It looks like the default is on my eclipse installation is 3.0 but it wont run on a Tomcat 5.5 server and probably not Tomcat 6.0 Is it related to the servlet spec that the Tomcat server supports? If so which version do i need to use for Tomcat 5....

Servlets and backend relationship

Hi, We can say Servlets are back end right? An interviewer once said "Servlets are not back end and for example Spring, EJB do". Is it right? Even spring MVC internally uses servlets to handle the requests right? Thank You. ...

Spring MVC 3.0 accessing Session Variable

Hi, I have the following problem, I have configured the following class which should be stored in session. <bean id="Users" class="com.doolloop.DlUser" scope="session"> <aop:scoped-proxy/> </bean> Then I in my Dispatcher servlet I would like to access this class user and set @RequestMapping(value="/authenticate.do",method = Reques...

Using java servlets and page attributes with jQuery and javascript

Currently I am using java servlets to set up Hashmaps, lists, and range of business objects and then pass them to a jsp page via request.setAttribute("myMap", myMap); How can I directly access this data in javascript/jquery? What is the syntax ? At the moment I am using jstl and EL expressions to loop through data and set the values of...