Skip to content
Advertisement

Tag: servlets

how to convert PrintWriter to String or write to a File?

I am generating dynamic page using JSP, I want to save this dynamically generated complete page in file as archive. In JSP, everything is written to PrintWriter out = response.getWriter(); At the end of page, before sending response to client I want to save this page, either in file or in buffer as string for later treatment. How can I

How can I get a Spring bean in a servlet filter?

I have defined a javax.servlet.Filter and I have Java class with Spring annotations. I want to get the bean UsersConnectionRepository in my Filter, so I tried the following: But it always returns null. How can I get a Spring bean in a Filter? Answer Try: Where usersConnectionRepository is a name/id of your bean in the application context. Or even better:

How to add filters to servlet without modifying web.xml

I’d like the ability to modify/configure filters in a different way than web.xml. Here is a static configuration of 2 filters. I’d like the ability to have one filter statically configured and allow that filter to load additional filters. I just wanted to know if anyone knows of lib that already has this. Using Servlet API 2.5 I’ve seen this

How can I upload files to a server using JSP/Servlet?

How can I upload files to server using JSP/Servlet? I tried this: However, I only get the file name, not the file content. When I add enctype=”multipart/form-data” to the <form>, then request.getParameter() returns null. During research I stumbled upon Apache Common FileUpload. I tried this: Unfortunately, the servlet threw an exception without a clear message and cause. Here is the

Advertisement