servlets

How can i inject servletcontext in spring

I need to write a junit test for a rather complex application which runs in a tomcat. I wrote a class which builds up my spring context. private static ApplicationContext springContext = null; springContext = new ClassPathXmlApplicationContext( new String[] {"beans"....}); In the application there i...

Writing a Servlet that checks to see if JSP's exist and forwards to another JSP if they aren't

UPDATE: To clarify a generic error catcher that catches 404's doesn't have enough granularity for me. I need to do this only if the jsp is in a particular directory and then only if the filename contains a certain string. /UPDATE I've beeb tasked with writing a servlet that intercepts a call to and JSP in a specific directoy, check th...

javax.servlet.ServletException: Servlet.init() for servlet Relay threw exception

I built application by using Netbeans and its working fine. But When i deployed on TOMCAT I am getting this error javax.servlet.ServletException: Servlet.init() for servlet Relay threw exception org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.connector.CoyoteAdapter.servic...

Configuring servlet for using spring

Hello How to configure my web application in Eclipse (based on Servlets and deployed to Tomcat) to use Spring framework. I need only IoC container (Beans only and ApplicationContext), not Spring MVC. How to configure web.xml for this? Regards ...

Why is no encoding set in response by Tomcat? How can I deal with it?

I had recently a problem with encoding of websites generated by servlet, that occurred if the servlets were deployed under Tomcat, but not under Jetty. I did a little bit of research about it and simplified the problem to the following servlet: public class TestServlet extends HttpServlet implements Servlet { @Override public vo...

Help with chat server

I am designing a chat server in java. The communication is Http based and not socket based. In the client side I have an applet. In the server side I have a servlet. Applet: I create a new thread to listen for incoming messages(GET method). The main thread is used to send messages(POST messages). The partial code is : public void star...

Amount of data stored in session

What technique should we use to make the httpsession object not loaded heavily with data. Example : Request 1 ---- > httpSession loaded with an arraylist of 50,000 different objects. session.setAttribute("data",arraylist); Request 2 ---- > httpSession loaded with an arraylist of 40,000 different objects. session.setAttribute("dat...

Hidden features of JSP/Servlet

I am interested in your tricks etc used when writing JSP/Servlet. I will start: I somewhat recently found out how you can include the output of one JSP tag in an attribute of another tag: <c:forEach items="${items}"> <jsp:attribute name="var"> <mytag:doesSomething/> </jsp:attribute> <jsp:body> <%-- when using jsp:attribut...

Java Web Application

I am interested in creating a simple web application that will take in user input, convert it to an XML file and send the file to a database. Coding wise I feel I am okay, it is just the general setup and what implementation to use I am a bit unsure of. At the moment I have a JSP page containing a form, the user fills out the form and...

How to use EJB 3.1 DI in Servlet ? (Could not inject session bean by @EJB from web application)

I am tying to merging web application(gwt, jpa) to an separate 2 application(business login in ejb/jpa and web client in gwt). Currently i can`t inject my beans from web application (simple servlet) I am using glassfish v3. module limbo(ejb jar) is in dependency of module lust (war). If I use lust with compiler output of limbo everythi...

Servlet doPost() Method setup?

I am interested in creating a web app that uses JSP, Servlets and XML. At the moment I have the following: JSP - Form input. Servlet - Retrieving Form data and sending that data to a java object. Java object (1) - Converts data into XML file....instantiates java object (2). Java object (2) - Sends that file to a database. On the re...

How to access Java servlet running on my PC from outside ?

I used Netbeans6.7 to write a servlet, when it runs, it opens a browser window with this address : http://localhost:8080/My_App/Test_Servlet, I replaced the "localhost" with my IP address, now it looks like this : http://192.???.1.??:8080/My_App/Test_Servlet, but I tried to access it from another computer outside my home, it can't read a...

Servlet 3.0 annotations <welcome-file>

Is it possible to set welcome-file tag from standard web.xml file by servlet 3.0 annotation ? <welcome-file-list> <welcome-file>PageName.html</welcome-file> </welcome-file-list> ...

Why a Swing app stops my Java servlet ?

I have a Swing runnable app which updates messages, then I have a Java servlet that gets messages from Paypal IPN (Instant Payment Notification), when the servlet starts up, in the init(), I starts the Swing runnable app which opens a desktop window, but 30 minutes later an error in the Swing caused the servlet to stop, how can that happ...

How to display Google Online Spreadsheets in browser using Servlets

I am looking for a solution on how to display Google spreadsheets in web page using Servlets. Something like this: user logs into the application and then opts to create a new google spreadsheet. I just want to know how to display google spread sheet in web application using servlets. I don't want to create a spreadsheet in my account a...

How do you access second parameter of a servlet's web.xml file?

Say in my web.xml file, I define a servlet like so: <url-pattern>/MyURL/*</url-pattern> How do i access anything passed in the * in my servlet? I'm planning to use use this scheme for pretty(-ish) URLs. ...

How to insert JSP functionality in Servlets?

How can I use Servlets to access the HTML uses of having JSP without having to have all my client-facing pages called *.jsp? I would rather do this than using all the response.write() stuff because I think it is easier to read and maintain when it is all clean "HTML". Is this is fair assesment? EDIT: What I'm going for is having the Ser...

Problem with detecting the value of the drop down list on the server (servlet) side

Client code is pretty simple: <form action="DDServlet" method="post"> <input type="text" name="customerText"> <select id="customer"> <option name="customerOption" value="3"> Tom </option> <option name="customerOption" value="2"> Harry </option> </select> <input type="submit" value="s...

GAE/J: unable to register a custom ELResolver

I need to register a custom ELResolver for a Google App Engine project. Since it must be registered before any request is received, as specified by the Javadoc: It is illegal to register an ELResolver after the application has received any request from the client. If an attempt is made to register an ELResolver after that ti...

request parameter is taking null value in servlets

Hi, I want to know how can I get the value of the request parameters "j_username" and "j_password"? After successfully login using form based authentication, I want my servlet to get the value of parameters "j_username" and "j_password", but I'm getting null as the value in both parameters. Could anyone please tell me how can I get th...