servlets

Threadsafe java servlet

I need to know if there are any issues with the below code as far as threading goes. I was always under the impression that so long as class level variables are not used threading is not an issue. public class UploadReferralImage extends HttpServlet { String CLASS_NAME = "UploadReferralImage"; public void doGet(HttpServletRequest r...

Read Browser/Client time from Http Servlet request header

Is it possible to read the Browser(Client machine) time when a request is made to the servlet? ...

Does a variable accessed by multiple threads in a java servlet need to be declared volatile?

In the book Java Servlet Programming, there's an example servlet on page 54 which searches for primes in a background thread. Each time a client accesses the servlet, the most recently found prime number is returned. The variable which is used to store the most recently found prime is declared as such: long lastprime = 0; Since this...

How can you get the original REQUEST_URI from within a Struts 2 Action reached via an apache ErrorDocument redirection?

How can you access the REQUEST_URI from within a Struts 2 Action? In perl/php/ruby it is readily available via ENV["REQUEST_URI"] and the like. In java it seems that the PageContext.getErrorData().getRequestURI() is what I'm looking for, but sadly, the PageContext does not appear to be defined within the action, either because the ErrorD...

Advice on GUI layout for security product

We've developed a security product which identifies certain types of unauthorized traffic on a network. The interface for displaying the messages is a Java Servlet generated page. At this point, the page is a glorified console log. There is a big text box with lines of text added as warnings and messages are generated. A couple of cool...

How can I get the filename of a servlet resource?

I'm writing a java servlet that calls a function in a jar. I have no control over the code in this jar. The function being called wants the filename of a configuration file as an argument. I'd like to bundle this file with my war file. If I put it in the war somewhere, what filename can I pass the function in the jar? Note that only a ...

Difference between status codes and error codes

folks, How can I differentiate between error codes and status codes in case of Servlet response? Is it right to say that there is some status codes in HttpServletResponse class which show errors. Or I've to use more definite way to differentiate between them? ...

How do I get URLs of other servlets from within a servlet

I have two servlets (S1 and S2). S1 renders a HTML-Page which acces S2 via an URL (img src="URL"). I know the servlet name of S2, but not the URL. The URL is configured in the web.xml of course, but how can I access that from S1? ...

Threads or JMS Which is better?

If i want to run a process (time taken to complete this process is in hours) in multi-user environment (thru tomcat-servlet) Which is better to implement this process in? 1) In Threads or 2) In JMS what are advantages and disadvantages? ...

How can one identify the operation to perform in a servlet?

Hello! I am trying to follow this example but I can't understand this part: Imagine also that the servlet's context path is myServer/myApp/servlets. The servlet container would direct a request with URL myServer/myApp/createUser.do myServlet to myServlet, because the request URL matches the pattern *.do. Servlet myServlet can extract th...

Servlets: where to store uploaded files?

In the PHP world it's common to create a directory called 'uploads' or something similar in the application folder. All uploaded files are then stored there, the database containing the relative paths to those files. In the Java/servlet world however, I'm not sure what the common way to handle uploaded files is. Getting the path to a d...

Installing Solr onto a hosted tomcat server.

I have installed and configured tomcat+solr on my personal linux machine and windows as well. I was able to get them working fine. I'm very new to Java and how the file structure works. (i.e. knowing where to put war files and what WEB-INF is) So now that I am ready to install solr and configure it on my clients shared hosting plan, the ...

Download servlet issue with ie 6

I need to write a download servlet in java to download a file from the web server. I am setting the response parameters as follows: resp.setContentType( (mimetype != null) ? mimetype : "application/octet-stream"); resp.setContentLength( (int)f.length() ); resp.setHeader( "Content-Disposition", "attachment; filename=\"" +...

Struts 2 development with Dreamweaver

Does anyone here use Dreamweaver for Struts development? I've been working on a web application using Eclipse/vi, but want to use Dreamweaver so that I can apply some nice looking Dreamweaver templates. I looked for tutorials on Struts development with Dreamweaver, but couldn't find any, and when I tried to import my page, a lot of stuff...

Making Velocity Template Object Static

Is it good to make Velocity Template Object Static? The situation is im going to use this object in (Servlet) multi user environment populating different data for each user-request with same template. ...

Finding server internet bandwidth thru java for streaming.

Following this thread. http://stackoverflow.com/questions/55709/streaming-large-files-in-a-java-servlet. Is it possible to find the total internet bandwidth available in current machine thru java? what i am trying to do is while streaming large files thru servlet, based on the number of parallel request and the total band width i am tr...

Calling a same servlet from different windows(or sessions)

hi! I have a servlet to display selected items. Whenever i call this servlet, it should be opened in a new window only if it is from different sessions. can anyone help me out in solving this problem? ...

java.lang.NoClassDefFoundError: com/hp/hpl/jena/shared/BadURIException on running servlet

I get a "java.lang.NoClassDefFoundError: com/hp/hpl/jena/shared/BadURIException" when running a very simple servlet. The error points back to the initialisation of the "Tagger" class. The code is as follows import java.io.IOException; import java.io.PrintWriter; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServl...

Configuring Tomcat to only raise one Servlet per application

According to my understand, Tomcat is allowed to raise as many copies of a servlet as it wishes in order to service requests. This forces my servlets to have no heavyweight state, and instead store all state in the (singleton) servlet context. Is it possible to configure Tomcat to treat my servlets as singletons, and always raise exact...

Display form-processing results on current page in JSP

Currently I'm able to send some form data from an HTML page to a Servlet, process it, and return the result by forwarding/redirecting to a displayresults.jsp page; However I'm wondering if there's a way to process a form submission in this fashion and then return the results to the initial page? So that whatever I wish to return shows up...