servlets

Correct syntax for a servlet that doesn't "return anything"?

What is the correct way of terminating a servlet that doesn't return any data to the client? The purpose of the servlet in question is to recive some data from an Ajax request and fire off a TCP message to a piece of hardware to tell it to change it's state. Do you have to specify a response at all? I've opted for getting a reference ...

displaytag problem

Hello everybody. I am trying to use displaytag for the first time and having a problem with the displaytag, that i seems not be able to solve. I googled for solution, but couldn't find nothing over internet. Everything else is working it is the only thing thats not working. Pretty much i am trying just do simple display of table. the ...

java servlets: better way to do multiple inserts and locking tables?

I'm currently running the follow code segment in a java servlet using the suggested PareparedStatement class. It is currently inserting inventory data into a SQL Server database of an accounting system. I have two problems. Because the insert statements insert data into 3 different tables, should I move these sql statements to tsql ...

Returning CSV file from Servlet using ServletOutputStream over HTTPS in Internet Explorer

I have a Servlet which is returning a csv file that is 'working' over HTTP in both internet explorer and firefox. When I execute the same Servlet over HTTPS only firefox continues to download the csv file over HTTPS. I don't think this is necessarily an Internet 6 or 7 issue described on MSDN : The message is: Internet Explorer ca...

Which class would load first when Web application starts?

I have a web application and two class files, First class is MyClass.class which is inside the abc.jar file (WEB-INF/lib/abc.jar) and Second class is YourClass.class which is inside classes folder (WEB-INF/classes/ YourClass.class). My question is which class would load first when the Application starts? And Why ? ...

How the attribute field of a HttpServletRequest maps to a raw HTTP request?

In Java, the attribute field of a HttpServletRequest object can be retrieved using the getAttribute method: String myAttribute = request.getAttribute("[parameter name]"); Where the HttpServletRequest attribute data is stored in a raw HTTP request? Is it in the body of the request? For example, I'm trying to create a raw GET HTTP requ...

JMX and Tomcat: create and use MBeans in a servlet

Hi all, does anybody have some ideas on how to achieve that? Or even a good documentation on how to do that? Basicly everything is done in a test standalone version (by a java client or jconsole I am able to call mbeans methods and everything works fine), but I need to put it in my Tomcat servlet.... Thanks for every suggestions! Ro...

http GET parameter SOMETIMES missing when using jsf

i have a servlet filter that handles errors for both vanilla servlets and jsf pages. if an error is detected the user is redirected to an error page where he can give feedback. then i try to read the value in the ErroBean it is there - SOMETIMES. :( about 50% of the time. FacesContext.getCurrentInstance().getExternalContext().getReque...

Passing Information from Java (Servlet) to CGI method?

Hey folks, I have this java servlet that grabs information from a form, I need to then take that information and pass it to a specific method in an .exe program and get the value that method returns. Is there a good way to go about doing this? ...

Running Ruby scripts under JRuby/Rack as if they were CGIs

Is there a way to map *.rb files to be executed under JRuby with the output being sent out to the browser like a CGI? Basically I'm looking for a JRuby CGI servlet. Ideally, I'd like to define a JRuby servlet in web.xml and then be able to put *.rb files in WEB-INF/ruby and be able to call them via http://servername/contextname/rubypro...

How can I create a servlet with jruby (running with jetty)?

Hi, I am pretty new to jruby and java and want to create a servlet in jruby while using jetty as web server. I am not sure if I am on the right way with the following code which shows the input form so far. I guess I have to extend now the HttpServlet class to handle the posted data but I don't know how to do this in this case and if it...

Why does my servlet stacktrace show "Unknown Source" for my classes?

I'm currently using Apache Tomcat 5.5.16 to serve a Lucene-based search API. Lately I've been having some NullPointerExceptions inside my servlet class. The class is called com.my_company.search.servlet.SearchServlet. With certain types of input I can routinely create a NullPointerException, but I'm having trouble figuring out where e...

Parameterized constructor in servlet.

Can I declare parameterized constructor inside servlet which is only constructor ? If no then why ? ...

What is a good strategy for caching prepared statements in Tomcat?

Hello, I am looking for a way to cache prepared statements in a servlet environment (specifically, Tomcat 5.5). This is meant to reduce the number of times that prepared statements are created, i.e. the number of times that connection.prepareStatement(sql) is called. My initial idea was to store PreparedStatement objects in the session...

The indestructibles - HTTP Parameters

I always wondered why there exists no removeParameters() method in Servlet API. What could be the motive behind this design? Here is a scenario: I am posed with a challenge in a proprietary MVC framework that I am compelled to use. This framework uses a Controller Servlet that hosts an algorithm in it's post method: doPost() { //creat...

Uploading a file in java using a servlet

I'm using javazoom for uploading protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException { PrintWriter out = null; JOptionPane.showMessageDialog(null, "Lets do this"); try { response.setContentType("text/html;charset=UTF-8"); try { MultipartF...

Is there a url rewriting engine for Tomcat/Java ?

How can we provide URL-Rewriting support for Tomcat/Java ? mod_rewrite provides this functionality for Apache and can modify URLs even before they reach the handler (e.g. PHP). Is there a similar tool in Java/Tomcat ? To be more specific we need modifications such as http://www.somedomain.com/person/1 Maps to http://www.som...

Ajax request parameters, what am I doing wrong?

I'm formulating an Ajax request using prototype in the following method: function updateServerStep(stepNumber){ alert("updating server step to " + stepNumber); var params = {stepNumber:stepNumber}; alert(params.stepNumber); var request = new Ajax.Request('UpdateStep', { method:'Post', parameters:params, ...

what is the servlet equivalent of Server.MapPath?

I've got a folder in my Web Application, fonts. I'd like to get the path for each of those files in that directory. How do I do that? In asp.net I'd do something like: System.IO.Directory.GetFiles(Server.MapPath("/fonts")) ...

javascript : having trouble passing form values to javascript and processing it to httprequest

I have a java servlet (class) which populates form data. //encode string for special characters String encodedString = URLEncoder.encode(desc, "UTF-8"); out_table.append("<form name=\"masinsert"+id+"\" method=\"GET\" action=\"MASInsert2\">\n"); out_table.append("<input type=hidden id=\"partnumber"+id+"\" name=\"partnumber"+...