servlets

Need Json results in a Table Format

Hi, I am getting results in json format, i need to display my results in a table format, Getting a input from html, executing it servlet program, the sparql query shows result in Json format, can anybody help me in showing the result in table format? response.setContentType("json-comment-filtered"); response.setHeader("Cache-Control","n...

Trouble implementing Singleton pattern in Tomcat web application due to Class Loader

I'm trying to implement a Singleton in Tomcat 6.24 on Linux with x86_64 OpenJDK 1.6. My application is just a bunch of JSPs and some static content and the JSPs make calls to my Java code. Currently the web.xml just looks like this: <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-insta...

Error with connection in my database servlet

Hello, I am writing a Database servlet, all seems well except that there seems to be an error in my connection import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Arra...

How to stream pdf document from servlet?

Hi,I am creating pdf document using jasper report and i need to stream that pdf document from servlet.Can anyone help me where i did mistake.This is the code snippet which i am using in my application. ServletOutputStream servletOutputStream = response.getOutputStream(); String fileName="test.pdf"; response.setContentType("application...

How to get JSON object in Servlet from JSP?

In JSP page I have written: var sel = document.getElementById("Wimax"); var ip = sel.options[sel.selectedIndex].value; var param; var url = 'ConfigurationServlet?ActionID=Configuration_Physical_Get'; httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); httpRequest.open("POST", url, true); httpRequest.onreadystatechange = handler(){ if ...

Pure JSP page navigation best practice?

What's the best way I can implement navigation links between various JSP pages of my Web app? Suppose that I have a list.jsp that shows a list of items. Then the user clicks on one of these items to view the item in more details in view.jsp. Now I need a link from view.jsp back to list.jsp. However, list.jsp is not the only page that co...

Is it possible to send json object from jsp page to servlet?

I have some data in jsp page entered by user. i want to send this data to servlet. i dont want to submit the form. I am using json object and adding the data into it using : var param; var url = 'ConfigurationServlet?ActionID=Configuration_Physical_Get'; httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); httpRequest.open("POST", u...

java methods and race condition in a jsp/servlets application.

Hi. Suppose that I have a method called doSomething() and I want to use this method in a multithreaded application (each servlet inherits from HttpServlet).I'm wondering if it is possible that a race condition will occur in the following cases: doSomething() is not staic method and it writes values to a database. doSomething() is stat...

How do I apply a servlet filter when serving an HTML page directly?

First off, I'm using Google AppEngine and Guice, but I suspect my problem is not related to these. When the user connect to my (GWT) webapp, the URL is a direct html page. For example, in development mode, it is: http://127.0.0.1:8888/Puzzlebazar.html?gwt.codesvr=127.0.0.1:9997. Now, I setup my web.xml in the following way: <?xml versi...

Create servlet from existing Java project

I have a Java Swing project for my class. I would like put it on my website so people can use it. However I'm not sure if there is a way to turn it into a servlet. Or do I need to know JavaScript? I'm confused. Is there a way to make my swing application into a servlet automatically? ...

GWT requestbuilder with asynchronous servlet 3.0

I have example project StockWatcher using requestbuilder to communicate with servlet (this example). I want to make servlet asynchronous. I have added the following lines to the doGet method: final AsyncContext ac = request.startAsync(); ac.setTimeout(1 * 60 * 1000); ac.addListener(new AsyncListener() { @Override public void on...

Can I send a POST form in an encoding other than of its body?

Hi gang, I've Html page that looks like: <HTML> <meta http-equiv='Content-Type' content='text/html; charset=gb2312'> <BODY onload='document.forms[0].submit();'> <form name="form" method="post" action="/path/to/some/servlet"> <input type="hidden" name="username" value="麗安"> <!-- UTF-8 characters --> </form> </BODY> </HTML> As you can ...

Servlet doesnt appear to execute in a threaded manner

I have developed a simple server using Tomcat which runs a servlet. The servlet calls a command line program - which takes about 20 seconds to execute then returns the result to the user via JSON. The problem is - if i make above 2 simultaneous requests, the servlet blocks until one of the previous requests is completed. An example of...

Maven archetype for simple Servlet application

Is there a Maven 2 archetype for a simple Servlet (2.5) web application? ...

Please clarify a few points concerning Java Servlets

suppose, I use Tomcat as a web container. Is it true that once all the servlets found in a web-app/WEBAPPNAME are init(IALIZED) then every change of a Servlet's property will be seen to every session. So session 1 changes a property userName of a Servlet1 from "user1" to "user2" session 1 is closed. session 2 starts. It will see "us...

Servlet receives OPTIONS instead of GET requests from jQuery?

All I want to achieve is to implement a servlet providing a json feed for my fullcalendar application. When I inspect http://arshaw.com/js/fullcalendar/examples/json.html with Bugzilla, I see that GET-requests are sent to receive the json feed. However, when I use this example within my scenario, fullcalendar seems to send OPTIONS-reque...

errorPage directive works, but error-page in web.xml doesn't?

I get jsp exceptions causing a forward to my error page when I put this at the top of my JSPs... <%@ page errorPage="/error.page" %> but when I try to do it globally with web.xml like so: <error-page> <exception-type>java.lang.Throwable</exception-type> <location>/error.page</location> </error-page> I just get a blank page...

Is it possible to evaluate a JSP only once per session, and cache it after that?

My site has a nav menu that is dynamically built as a separate JSP, and included in most pages via <jsp:include />. The contents and styling of the menu are determined by which pages the user does and doesn't have access to. The set of accessible pages is retrieved from the database when a user logs in, and not during the course of a se...

Load a jsp-file from a servlet (App Engine)

I would like to load a jsp file from a servlet-class I got in my App Engine project. I has been able to load jsp files by adding them to the web.xml file but is there any way to load them directly from a servlet class? Edit: I have tried this without success (no error msg or anything) req.getRequestDispatcher("file.jsp").forward(req, r...

Access resources (CSS, HTML, images, JS) through servlet

I'd like to know if anyone has a solution to access resources of a website through a servlet only. I have all my resources under WEB-INF. In other words, I don't want users to have direct access to any of my resources. ...