How to get any http session by id or all currently active http sessions within web application (Java 2 EE) in an elegant way?
Currently I have a WebSessionListener and once session was created I put it in ConcurrentHashMap() (map.put(sessionId, sessionObj)), everything ok, I can retrieve HTTP session from that map in any time by session...
Hello
As I understand it and have used it, AJAX is used to make requests from the client to the server and to then update a HTML DIV on the client with new content.
However, I want to use AJAX from a client to a servlet to verify the existence of a URL. If the result is bad, I can set an error message in the servlet and return it to t...
I have two web applications running in same Servlet container (Tomcat), A and B. These two connect to each other using Spring Remoting. On startup, B needs to call A to open a connection automatically, it's basically a really simple authentication call.
However since B is (in my case) loaded before A, B's application context blocks unti...
I have a servlet that handle certain HTTP requests and responses. I want to log the response body before sending back to the client. Is there any way that I can capture the response body before it is send as a HttpServletResponse object from the servlet?
...
I am new to JSP and Servlets.
What i want to know is the best way to pass some customized message to client web pages.
For example suppose i have a web page say student.jsp which has a form,to register a new student to our online application.after successfully inserting all the fields of the form,
user submits the form and data is subm...
I found some hints on Stackoverflow how to enable JSP support in Jetty by editing web.xml.
But can this be done programmatically, without any web.xml?
(Preferable without writing an own servlet for that)
Even REST services support with Jersey can be enabled programmatically in Jetty. I can't beleave that it's so hard for such wide-spre...
Hi,
In my web app, a user can click an item in a list, and I modify the url in their browser:
<li>Horse</li>
<li>Cow</li>
<li>Goat</li>
function onListItemClicked() {
window.location.hash = item.name;
}
this will change the url in the user's browser to:
www.example.com#Horse
www.example.com#Cow
www.example.com#Goat...
When I click on link 1 and then, before the response was received, click on link 2 on the same page, I get a "Page Expired" error from Wicket. Is Wicket conceptional capable to do such a concurrent processing?
Any ideas why Wicket loses the session (it seems to reside on tomcat though)?
...
I want to extract the body of a HttpServletResponse Object.I know we could use a filter to do that but i was wondering if there is any other way in which i can get the body content.I just want to extract the information from my printstream object.Any help or code samples will help?
Thanks
...
We would like to implement a "fault barrier" strategy for managing exceptions in our applications. One thing our applications have is the concept of a "passback" response, basically a no-op, which we'd like to return in preference to throwing 500, 400, etc. HTTP status codes - e.g. our external facing applications should always return a ...
I've recently inherited some code, within which I've found a JDBC connection being initialized in a filter and added the the HttpSession for each user. That connection is then reused throughout various portions of the web application for the user. This immediately stood out to me as a code smell. I'd like to go back to the developer w...
My java webapp fetches content from a textarea, and e-mails the same.
The problem I'm facing is that the newline character in the textarea message is not preserved when reading the same using
request.getParameter("message");
Any clues how it can be tackled?
TIA.
EDIT:
The content in the textarea is:
abcd
abcd
CODE:
String ...
i'm triing to get the output from a servlet on an android phone
this is my servlet:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package main;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletExc...
The reason to do that is because I want to use Runtime.exec() using the same classpath as my servlet.
The class I want to run is within WEB-INF/classes/my/package/.
So I want to build a cmdarray as String[] {"java","-cp", my_servlet_classpatch, "my.package.myclass"}
I just can't find a way to get my running servlet classpath.
NB: This ...
We've got some Pure Servlets (pure Java classes following the Servlet API, no framework) that we'd like to include in a project that relies heavily on the Spring Framework.
What's the best way of including these servlets in the project, when all the new code we're writing is making heavy use of Spring 3 features?
...
How do I throw a 404 error from within a java servlet? My web.xml already specifies what page to show when there is a 404, how do I throw a 404 from within a servlet?
...
Hi
i like to build web application and im trying to think about way to reduce cpu/memory
what will be faster for tomcat to use servlets to get the requests and render back the HTML
or using jsp ?
...
Hello
I'm writing my first JAVA servlet and I have a question.
May be it's important to say that my servlet will be called from Google Web Toolkit (AJAX)
First thing that I do is to create PrintWriter and start to write in it my JSON output
PrintWriter out = response.getWriter();
...
out.println("[");
out.println(" {");
out.println...
Hello everyone.
I need to initialize every new http session with some values. How do I do that?
I tried to create a session-scoped component and initializing session in @PostConstruct, but session-scoped beans are not eagerly created until I request access them.
...
For debug reasons, I want to see the ouput of my ResponseWriter directly in standard output. Because the response will be processed by JavaScript I am not able to see the output there.
Is there an easy solution to redirect the ResponseWriter to standard output?
...