servlets

JAX-WS servlet filter exceptions

I have a client/server application that communicates via SOAP. The server-side application is a JEE app that exposes web services using JAX-WS. I have a servlet filter setup to perform certain checks before a service is invoked. This is all working pretty well, except for exception handling. If I throw an exception from the filter, i...

How can I create Thread safe JSP page

Hi All, I want to create a Thread safe JSP page. It is possible in Servlet by implementing SingleThreadModel interface but I don't know how to do it in JSP page. ...

Struts2 getting request object as null

Hi, I am facing a strange error in Struts2, I am getting a null pointer exception when trying to set attribute into request scope, Struts Problem Report Struts has detected an unhandled exception: Messages: File: org/apache/catalina/connector/Request.java Line number: 1,424 Stacktraces java.lang.NullPointerException ...

HTTP Status 405 - HTTP method POST is not supported by this URL

I am getting the error HTTP Status 405 - HTTP method POST is not supported by this URL when I use the following code(below) ... the line causing the trouble (apparently) is getServletContext().getRequestDispatcher("/EditObject?id="+objId).forward(request, response); package web.objects; import java.io.IOException; import java.sql.SQLEx...

Parameters not passing from HTML form to MySQL (via Tomcat, Eclipse(IDE), Servlet, and Java Bean)

I am designing a small web application for learning purpose using Apache Tomcat, Eclipse, Java EE (Servlet, JSP, Bean), MySql Database as backend. I have configured Eclipse to include Tomcat, MySql connector. The Project: A HTML form for entering UserName, Email, and Password. Servlet for passing parameter to Java Bean. Java Bean t...

X-JSON servlet filter:GA

Hello I have a specific need to filter out the X-JSON header attribute and its data content. It is actually my first foray into servlet filters so it is a general audience question. I have investigated the structure of the filter api. What I do not understand is how, I believe, in the HTTPServletResponseWrapper I filter for a custom a...

Accessing a JSF managedBean from a Servlet

Hello all. I need to know what's the best method for accessing a JSF managedBean (which is defined having application scope) from a servlet. Currently I have something like this in my servlet: MyApplicationScopeBean bean = null; try { FacesContext fContext = FacesUtil.getFacesContext(req, resp); ServletContext sc = (ServletCon...

How to obtain request attribute in JSP using EL?

I know this isn't hard, but I'm not having any luck. I want to make fooList from a Servlet available in a JSP. So in the Servlet I have: request.setAttribute("list", fooList); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/myJsp.jsp"); dispatcher.forward(request, response); Then in the JSP, I want: <c:for...

java won't compile with RequestDispatcher, classpath set correctly

I'm using ubuntu and I've been trying to compile based on my research and my previous posting regarding to compilation issue. This time I suspect CLASSPATH but cannot figure out what is wrong really. (The java file I want to complie) /home/makun/tomcat/apache-tomcat-6.0.26/webapps/head_first /src/com/masatosan/registerservlet/RegisterS...

How Do I Keep HttpSessions Alive in Tomcat?

I'm having a bit of trouble with Session timeouts in my Tomcat served web application. From reading over Tomcat's documentation, sessions expire after a time which can be configured in the web.xml file. <session-config> <session-timeout>30</session-timeout> </session-config> Quesion) Does this mean 30 minutes from when the...

Open pdf file from jsp page

I am trying to open a pdf file using ServletOutputStream in JSP. The code is: response.setContentLength(statementVO.getOutputStream().size()); response.setContentType("application/pdf"); response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "pu...

Java servlet as proxy for Apache web server

I have an apache webserver that is used to serve php and static web files. In order to use active directory authentication i've written some code that can connect to AD through JNDI and authenticate usernames passwords and groups. What I would like is to map all requests to pages in apache through my servlet in order to make sure that a...

Starting a Servlet from a java class like from HTML code

Hello, What I am trying to do is to run a simple Servlet from a java class. Actually I have a Servlet1 that is started from an html code through a post action. That servlet outputs some other html page but also calls a Java class. What I try to do now is to start a Servlet2 that outputs html code from that java class. I did: URL url ...

Detect if user changed file extension to upload?

Using a Java servlet, is it possible to detect the true file type of a file, regardless of its extension? Scenario: You only allow plain text file uploads (.txt and .csv) The user takes the file, mypicture.jpg, renames it to mypicture.txt and proceeds to upload the file. Your servlet expects only text files and blows up trying to read t...

Not able to parameterize an ejb function

Hi I can write a ejb like this... @Stateless public class AnotherBean { @PersistenceContext(unitName = "VoidJPA-ejbPU") private EntityManager em; public void newTest() { System.out.println("Testing"); } } And call it using this from a servlet @EJB private AnotherBean nsb; ... ... nsb.newTest(); But whenever i put a variabl...

Can I use a JSF navigation rule in a servlet for redirection?

I have to use a few servlets in my Web application. The servlets perform a bit of processing and then redirect the user to an xhtml page. I already have navigation rules in my app, which I'd like to re-use in my servlet. Example: <navigation-case> <from-outcome>bookingFailed</from-outcome> <to-view-id>/SecureUser/Reservation/N...

how to solve error http status 404 in servlet jsp

Respected Sir/Mam, I am trying to run some basic servlet and jsp program with Tomcat. but it gives some error. I am using Tomcat 6.0.29 and jdk 1.6.0_21. I have done everthing properly. But when i click on WebAppl link in Tomcat then it gives below error HTTP Status 404 - /WebAppl/ type Status report message /WebAppl/ description T...

Calling a servlet from JSP file

Can I call a servlet from JSP file without using a HTML form? ...

relative url and absolute url difference

What is the difference between relative and absolute url in servlet container. for example if there is an jsp called forum.jsp under webinf folder. when i want dispatch the current request to the jsp from the current jsp file which is under the same webinf folder, is the following correct way /forum.jsp relative url means relative to...

How to get the IP address when a session is created ?

In my grails application, I have implemented the interface HttpSessionListener to listen for session creation as given below: class MyHttpSessionListener implements HttpSessionListener { public void sessionCreated(HttpSessionEvent event) { log.info "***************** Session created: id= ${event.getSession()?.id}" } } ...