servlets

Servlet and JSP? When to use them?

Possible Duplicate: When do you use a JSP and when a Servlet? I am new to JSP and servlet. After reading some of the tutorials in web about servlet and JSP, one question have come to my mind actually depending upon what criteria we have to prefer servlet or JSP. In other way when to choose servlet and when to choose JSP? ...

Scala actor to non-actor interaction (or synchronizing messages from an actor to a servlet)

I have the following scala code: package dummy import javax.servlet.http.{HttpServlet, HttpServletRequest => HSReq, HttpServletResponse => HSResp} import scala.actors.Actor class DummyServlet extends HttpServlet { RNG.start override def doGet(req: HSReq, resp: HSResp) = { def message = <HTML><HEAD><TITLE>Rando...

Roles in JSP and Servlet

I want to create an application with three kind of user : administrator, professional and simple user everyone will see special pages, so I must use roles. Do someone have a good example or tutorial on how to do this ? thnx a lot ...

call servlet from html form without web.xml deployment descriptor

How can I call a servlet from the form's action without using the web.xml deployment descriptor? ...

How do i get the URL of an <ice:graphicImage> element?

Hello, I'm trying to do a thumbnail gallery on my web page so that when one is clicked the full size image is shown. The images are stored in a backing bean and are shown with an tag. <li> <a href="????"> <ice:graphicImage value="#{screenshot.image}" styleClass="thumb"/> </a> </li> When on the page, I see the...

Problem with writing file in servlet deployed on tomcat

I wrote servlet that writes an image to the root directory of my app and then delivers it to client when it gets GET request. Everything works fine when i test it in Eclipse with jetty (came with GWT plugin). But when i move it to Tomcat, i get filenotfound exception (because image is not written at all so it can't be returned to client...

Where we have to put the .class file in Tomcat Directory

Where do I have to put my *.class file in Tomcat Directory? In my Java-Complete Reference book, they told to put it in C:\Program Files\Apache Tomcat 4.0\webapps\examples\WEB-INF\classes. But now i'm using Tomcat 7.0. There is no folder exists with the name "examples" in webapps. How can I fix this? Can you tell me links that will ill...

Getting an instance of a running servlet

Hi I am using GWT and I have a problem. I want to access the running instance of the servlet declared in web.xml. How can I do this?? I need to have a main running in the same JVM as the servlet. I have an interface between the main class that the servlet implements. This interface allows the main to fill a queue in the servlet. Need he...

Is it possible to forward or redirect from a servlet filter after the response has been comitted?

The logic is that the filter gets hit, the condition is not true, so it goes through the filter chain. After the response is committed, the filter gets hit, and the condition is now true (a request attribute was set). It goes in to execute the forward, but the page never forwards. I know this has something to do with the response being c...

Calling servlet post from jsf in different war

Hi, I want to call a Servlet which exists in a different war from my war. When user clicks a button we need to call the post method of the servlet. To implement this I did see an existing example which is slightly different but works in that case. I am using jsf, so in the jsp there is a h:form with another html form inside of it. Below...

HTTP response caching

Hi, I want to ensure that my servet's response is never cached by the broswer, such that even if two identical requests are made (a nanosecond apart), the server is always contacted. Is this the correct way to achieve this: class MyServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse r...

JSONObject from String

how can i get JSONObject from request(HttpServletRequest) in servlet.. ...

Different session timeouts for different users in same web app

I have a requirement within the same web application to set 2 session timeouts. 60 minutes for regular users and 3 hours for admin users. I am told this is not possible and I will need to host a separate web app for the admins. Is there any workaround? UPDATE: Thanks to Bozho and Kurt's replies - I have a followup question. Does ses...

starting a servlet from a main in java

Hi, How can you run a servlet on a server without putting it in the web.xml. I want to start a server from main and pass what servlet it should run Thank you ...

Log only http servlet response headers

This is a question related to http://stackoverflow.com/questions/3242236/capture-and-log-the-response-body. What if I only want to log the response headers, and not the entire body? Is there a different approach than described in the linked question? ...

How to disable default servlet container session?

In J2EE web application, how do I disable the default HttpSession creation? We have our own way of tracking session, we don't use default jsp/servlet session but the default session sets cookie in browser which I would like to avoid. Right now on every JSP page we specify as session="false" in page directive but often some developers mi...

Scala/Java servlets: How to output < in the HTML code instead of &lt;

I have a servlet coded in Scala. I have some code like this in there: def message = <HTML><HEAD><TITLE>Test</TITLE></HEAD><BODY>{value}</BODY></HTML> def value = "Hello <BR/> World" The corresponding HTML code generated for value is Hello &lt;BR/&gt; World How do I get it to generate the HTML code (shown below)? Hello <BR/> World...

Using JSP Bean in a Servlet

So I'm using a bean on a JSP page to store some data, like so: <jsp:useBean id="data" class="myclass" scope="session" /> Is there anyway to access this bean from a servlet at a later time in the same session? EDIT: Apparently I'm not accessing the same session when I load the jsp page and the servlet. I'm printing out the session ID ...

JSP page and Servlet reporting different session IDs

I'm setting a bean with some data in a JSP page, but then in my servlet when I try to access the value, I get a null value back. I printed the session IDs in both pages and I'm getting different values. Does anyone know what might be happening? Thanks. ...

LTPA Token Not Changing

When I log out of an application on WebSphere and back on, the LTPA token is unchanged. I thought it would change because session tokens are supposed to be unpredictable. ...