servlets

Problem deploying servlets in JBoss 5.1 on eclipse.

Yesterday I created a simple image servlet and attempted to deploy it. I am getting an error on JBoss startup, and then further errors on trying to invoke the servlet. I spent about 8 hours yesterday searching the web for answers and trying different scenarios. I ended up making my JBoss problems worse and then fixing them, but I never ...

Set request attributes when a Form is POSTed

Is there any way to set request attributes (not parameters) when a form is posted? The problem I am trying to solve is: I have a JSP page displaying some data in a couple of dropdown lists. When the form is posted, my Controller servlet processes this request (based on the parameters set/specified in the form) and redirects to the same ...

How to select saxon TransformerFactory in Java

In my web application I need to use Saxon TransformerFactory to use XSLT 2.0 but I can't use setProperty method because I haven't this right on the web server and there is a Security Manager. So i have read that it's possible to do this: Use the Services API (as detailed in the JAR specification), if available, to determine the clas...

details of request.getSession() statement?

I understand that if we use the following statement HttpSession session = request.getSession(); Will create the Unique session id, Create Cookie and associate Cookie with the Session id. and helps the container to keep track and identify the clients. Yes, My question, is there a possibility for me to see the cookie header and Unique...

checking session in servlet and jsp

Hi, In my web application i neet to check session already exist or not. i want to check this in my servlet and in jsp also. is there any way to check this. Thanks ...

"Forwarded" request

Hi people, i have a problem with implementation of "forwarded" request in java. So i have a servlet, and i want that for request localhost(servlet works on localhost) i receive a page(page defined intern in programm) and can proceed to work with this page using localhost. Example: page defined: stackoverflow.com So if i type in browser ...

Working/Include Direct of a Servlet

Hi there, I'm currently starting to learn to use java to create dynamic websites. I've started using a servlet and the template engine 'velocity'. My Environement: WebContent/ WEB-INF/ gallery/ template.file My Question: I want to use the "template.file" as template. WHAT filename/path do I have to enter to reach m...

[JSP, MySQL and Servlets] ResultSet loses first value

Code seems to work fine, but I noticed whenever I queried a string with only one result, it returned nothing. Somehow I am skipping the first result I think but have no idea why. else{ Conn con = null; try { con = new Conn(); } catch (Exception e) { e.printStackTrace(); } String sql = "SELECT productname, qu...

How to manage db connections on server?

I have a severe problem with my database connection in my web application. Since I use a single database connection for the whole application from singleton Database class, if i try concurrent db operations (two users) the database rollsback the transactions. This is my static method used: All threads/servlets call static Database.doSom...

Writing image to servlet response with best performance

Any advices, practices, experience? Thanks. ...

Can't instantiate javax.servlet.ServletException

Hello, experts! I am trying to create instance of class javax.servlet.ServletException with following code public class MyTroubleViewer { public static void main(String[] args) { javax.servlet.ServletException servletException = new javax.servlet.ServletException("Hello"); System.out.println(servletException.getMessage()); } } ...

Servlet Session - switch from URL Rewriting to Cookie

Situation: I have a "dumb" Javascript frontend that can contact some kind of SSO middleware (MW). The MW can obtain sessions by issuing requests that contain authentication credentials (username, password). I.e. the session will be created for a certain user. My frontend needs to "restart" the session to gain the user's permissions to t...

How can something like BOSH be implemented using Java Servlets

BOSH (Bidirectional-streams Over Synchronous HTTP) is a sneaky way of implementing 2-way client-server communication in situations where true server-push is not allowed, most obviously to let a server push data to a browser client without having to use client polling. It works by the client sending a request to the server, and the serve...

Does a servlet-based stack have significant overheads?

I don't know if it's simply because page-loads take a little time, or the way servlets have an abstraction framework above the 'bare metal' of HTTP, or just because of the "Enterprise" in Jave-EE, but in my head I have the notion that a servlet-based app is inherently adding overhead compared to a Java app which simply deals with sockets...

Websites using JEE

Hi guys, I have a simple question, but I can't find out the answer. I'm wondering if we can see that a website is built using the JEE technology, or servlets/JSP. I think it could be possible to look for specials pages from the server (404, wrong parameters, ...) in some cases, but what about the everyday use ? In fact, I look for a co...

Calling a SLSB with Seam security from a servlet

Hello, I have an existing application written in SEAM that uses SEAM Security (http://docs.jboss.org/seam/2.1.1.GA/reference/en-US/html/security.html). In a stateless EJB, I might find something like this: @In Identity identity; ... if(identity.hasRole("admin")) throw new AuthException(); As far as I understand, Seam injects the...

Testing a servlet static method not allowed?

When I try from within JUnit I enter: public InvocationTargetException(Throwable target) { super((Throwable)null); // Disallow initCause this.target = target; } I know that I could put that code in an outer class and have servlet call it. Can I not test a static method of a servlet in Java EE 5 container, from a JUnit test m...

Cookie questions in Java

Hi, How do I differentiate between multiple cookies set through my site? I am setting two kinds of cookies one to see if the user has visited the site or not and an other one for authentication. How do I differentiate between these two? I get both of them when someone accesses a page after authentication. Do I add extra information to t...

Print the jena result set in html(servlet/jsp).

I'm using servlet for manipulating ontology. I got the result of my SPARQL query and I want to display(print) that result in JSP (Servlet). Following code segment can be used to print the result in console. com.hp.hpl.jena.query.Query query = QueryFactory.create(queryStr); QueryExecution qe = QueryExecutionFactory.create(query,model); ...

Get request URL from jsp

How can i get request URL from JSP. If i use following code within JSP i get - System.out.println("servlet path= " + request.getServletPath()); System.out.println("request URL= " + request.getRequestURL()); System.out.println("request URI= " + request.getRequestURI()); I get path to view(jsp) with jsp prefix. But i want to get URL ...