servlets

Why can not we call servlet constructor instead of init method to initialize the config parameters?

Hi I like to know why dont we call servlet constructor instead of init method to initialize the config parameters. THanks ...

MyFaces 1.2.8 causes Tomcat 6 to crash on deployment

Hello I've got a JSF app built with MyFaces 1.2.8, Facelets 1.1.14 and building it with Tomcat 6 through it's plugin in Eclipse Ganymede. I've just installed the latest versions of the above libs and on build, the app deploys ok and the server goes to start and immediately I get this: javax.servlet.ServletException: javax.crypto.BadPa...

cookie name is truncated in Servlet 3.0 HttpServletRequest (Glassfish V3)

I'm porting our Web authentication/authorization middleware for use in containers implementing the new servlet 3.0 API (Glassfish V3 in this case). The middleware pulls cookies from the HttpServletRequest filtering on cookies with names of the form "DACS:FEDERATION::JURISDICTION:username". This works fine in the version 2.5 servlet API ...

Servlet, JSP, JavaBeans and HTML form

Hi, I'm working on a servlet that makes a connection to a database gets the information of one of the tables ans sends this information to a jsp file. This file will print on the brower the information table, adding radio buttons that allows us to choose one of the rows. The servlet looks like this: List<InfoBean> items = new ArrayList...

iText image in java servlet

Hi, I'm doing the letter generation with iText (pdf/rtf) in java servlet and got a problem with accessing images. The images are in the WebContent/images folder. When I run it in a local server and pointing the full path of images directory (c://eclipse/myproject/WebContent/images/letterHead.jpg) its working, but it fails running on the...

Redirecting the response from a filter throws an IllegalStateException

I am writing a filter that will handle all authentication related tasks. My filter is a standard servlet filter as shown below @Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { UserSession attribute = (UserSession)request.getSession().getAttribu...

How do I reload servlet classes without restarting my web application?

I want to reload just my web layer classes without reloading my service layer classes (which take longer to initialize and change less frequently). There are no references from my service layer into the web layer and I can create a whole new instance of the web layer without problems. I can conceive of a solution involving complicated ...

How to prime cache and keep it updated

I'm planning on caching some information using ehcache. Normally, I would follow the pattern: if data in cache return from cache else lookup from source put into cache return data But for this data, I'd like it to always be in memory. I'd prefer to do: Populate cache while appserver starts up (I'm using JBoss) Have a "...

How to call servlet file using Html

I created one web application project. It contains a servlet file and a HTML file. How do I call servlet file from HTML? ...

calling jasper file from servlet

hello friends i am new to jasperreport and dont know how to call jasper file from servlet me and my jasper file contains pie chart also plese help ...

I have a variable number of textboxes how do I retrieve their values in a servlet

I have a number of textboxes that will be displayed with their existing values. I want my servlet to be able to get all their values and then update the database with the the values that have changed. How do I get the values? Is there some way to put them into a HashMap with the id or name as the key and the value of the textbox as the...

This code is not submitting to a form? Why

Since I am using get I expect to see the submitted values appended to the queryString but instead all I see is the URL of the servlet being called with nothing added at the end. classes = new HashMap(); classes = (HashMap) request.getAttribute("classes"); %> classIds = new HashSet(); classIds = classes.keyS...

Image Upload Servlet not working in Chrome, but works in other browsers

I have tested this servlet and it works well, except in Google Chrome it jsut doesn't display image. What could be wrong in this example code that makes Chrome not to display image? http://balusc.blogspot.com/2007/04/imageservlet.html ...

Multiple "pages" in GWT with human friendly URLs

Hi. I'm playing with a GWT/GAE project which will have three different "pages", although it is not really pages in a GWT sense. The top views (one for each page) will have completely different layouts, but some of the widgets will be shared. One of the pages is the main page which is loaded by the default url (http://www.site.com), but...

How do I upload a file from a Java servlet to a location on a web server within Tomcat/webapps

How do I upload a file from a Java servlet to a location on a web server within Tomcat/webapps. I am using Commons upload. I have a location such as myserver:8080/myapp/mylocation where I want to put the files that are uploaded. I tried using getServletContext().getRealPath("/"); to find where I am and then appended that with mylocatio...

Modify web.xml using Ant

Is there any way to strip elements out of a web.xml file using ANT? For example I have certain servlets I use for Unit Testing defined in the web.xml that are unnecessary in the production environment is there a way to strip these out or do I need to have a separate production web.xml file? Thank You. ...

How to get multiple selected values from select box in JSP?

I have a html form which have a select list box from which you can select multiple values because its multiple property is set to multiple. Consider form method is get method. The html code for form is as follows. <html> <head> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="get" action="display.jsp...

How can I tell why a servlet filter has been invoked.

In the servlet 2.4 spec you can define dispatchers in the filter config [REQUEST | FORWARD | ERROR | INCLUDE]. When the filter is invoked, how can I tell from which condition it was invoked from i.e. how can I tell if it was a request or an include or a forward? ...

Communication between JSP and Servlet?

I have a jsp page that communicate with a servlet back end. Up until now, the way I communicate with that servlet is via .getJSON() which is a JQuery method. This work great if the data I want to send back is in the form of {key:value}. However, now I need to send a bit more data then that. The largest table in my database, contain rough...

HttpUrlConnection Post causes the browser to download the response JSON in Java Proxy

Hi all I'm making call to Alfresco Webscripts which return JSON. I do this using GET requests which all work perfectly. If I do a file POST however, the Alfresco server receives the file correctly and sends back a JSON response, but this time the response causes the browser to prompt for a download instead of the letting Javascript proc...