servlets

Using a file form field with a Java servlet

I am tring to retrieve a filename or the file itself for use in a java servlet (from a web form). I have a file form field: <form enctype="multipart/form-data" method="post" action="SaveDictionary.do"> <label> <input type="file" name="dictionary_file" id="dictionary_file" /> <br /> </label> <label> ...

to display csv file in IE using servlet

Hi, I have a csv file in D drive.I need to display it in IE using servlet.Can any one help me? Thanks ...

Looking for a simple, secure session design with servlets and JSP

I'm working on an intranet-only web application (J2EE) that requires some basic security features. There will be relatively few authorized users for the site, but I still need to implement some sort of secure session. The basic flow I'm looking at is visit site => log in => use site => log out when done (or automatically log out when th...

IllegalStateException shutting down webapp with PicoContainer

I have a Java webapp that's using PicoContainer for dependency injection. When I shut down the app, I sometimes get the following stack trace repeated a few times in my error log: 2009-11-18 17:32:29,352 ERROR [/] - Session event listener threw exception java.lang.IllegalStateException: Cannot stop. Current container state was: STARTE...

Migrating from Tomcat 5.5.x to 6.0.x.

I'm migrating an mature application from Tomcat 5.5.x to 6.0.x. What are the sticking points that I need to make sure that I address? I use a couple of Tomcat's services that I suspect will need adjustment... The logging mechanism: I altered the conf/logging.properties to include my webapp. The Resource of type="javax.sql.DataSource...

How do I access a text file from within my war

How do I know what file reference to use to get a file from my WAR. The structure of the WAR is: WAR src - model - web build   WebContent     META-INF     WEB-INF       LIB The JSPs are under WebContent, I have put the config.txt file under the WebContent folder and tried to get to it with Buffered...

How do I make an search bar at the top of the page like on stackoverflow.com?

I need to make the search bar at the top of the page like stackoverflow.com have in its website. I need some sample code for jsp/servlet for performing the operation for searching. What operation it provide while one write something at the search bar. I want to search anything but into my website only. Please give me some idea... Thank...

how to implement a search from search box?

I've got a requirement where a user enters a few terms into a search box and clicks "go". Does anyone have any good resources on how to implement a dynamic search that spans a few database tables? I am using jsp,servelt,jpa as front end and mysql at back end of my project. Thanks, Satya ...

web service client reference, in a servlet

I have a servlet, and that servlet uses a .net web service to perform some function. To do this, I created the webservice client in Netbeans using the "jax-rpc" style client. Let's say that my service name is "Tester". Then two of the generated classes are called "Tester", and "TesterSoap". To get a reference to the web service, I need...

Reverse Ajax + JSP-Servlet

Hi, We are trying to create a reverse ajax in our project. I've checked on the net and didn't find something concrete. I was unable to run any of the tutorials provided successfully. My object is: to provide on-screen alerts (like a pop-up) when ever there is an even pushed from the server (it could be high cpu usage/ram, anything). ...

Remote Servlet Comms

I have two servlets A & B. On B i intend to have a a method isAvailable() which A will call to check the status. If this method returns true then im going to pass it an object to B. On doing a bit of reading i'm seeing a couple of options non of which im that familar with. JNDI with remote EJB , RMI or simple HTTP (not sure how youd do...

Best MVC tutorial/example for JSP/Servlet?

Can you provide a link for best or elegant MVC tutorial/example for JSP/Servlet? I am going to refactor a JSP based application. so I need a good reference or template to start with. I maybe not going to use any framework. ...

Sending Email Using A Servlet

I have to send an email through a servlet, I have tried a bunch of codes, but none of them work with an gmail account, any ideas? java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); Properties props = new Properties(); props.put("mail.transport.protocol", "smtp"); props.put("mail.smt...

How to grant access to authenticated users in Tomcat 5.5.x?

I'd like to be grant access to authenticated users in my web application without requiring them to be a member of a specific role. My first guess was to specify <role-name>*</role_name> in my auth-constraint, however it seems that this just means grant access to any role defined in my web-app, not grant access to any authenticated user....

Should heavy-weight java objects be saved in session via setAttribute? Is it a good practice in servlet development?

I mean if I construct a heavy object [including collections and a bunch of props ] and I need to query that object from time to time during the session life, should I save it with setAttribute or do I need to persist it somewhere? What are best practices here? ...

Sending an Email Using Java

try{ Properties props = new Properties(); props.put("mail.smtp.host", "ipc-smtp.bits-pilani.ac.in"); Session sess = Session.getInstance(props, null); sess.setDebug(true); Message msg = new MimeMessage(sess); InternetAddress addressFrom = new InternetAddress("[email protected]"); msg...

Session Problem

The HttpSession session = request.getSession(true); and HttpSession session = request.getSession(); both creates a new session if there is none present. My problem is that i want to invalidate() the session if its allready present and then create a new one. I that possible ..i mean is there any way out to achieve this..?? ...

Should a servlet explicitly return at the end of doGet/doPost?

Is there any difference between explicitly returning at the end of doGet or doPost-methods, and just letting the method return "by itself"? public void doGet(HttpSerlvetRequest req, HttpServletResponse resp) { <my code here> return; } public void doGet(HttpSerlvetRequest req, HttpServletResponse resp) { <my code here> } ...

Overriding the JSP servlet (filter "*.jsp") to wrap in an authentication model

Hi there, Can the JSP servlet that filters on *.jsp (org.apache.jasper.servlet.JspServlet in Tomcat 6) be extended in some way so whenever someone goes to a JSP page I can do some server side authentication to check whether the user can view the page. Our current technique is a taglib in a common include that is imported into each JSP ...

Manage Session when broswer has disable cookies

Hello All... I wants to know that How can i Manage Session if the client browser has disabled cookie feature.. If I wants to implement it in simple JSP - Servlet, then how can I do that ? Thanks in advance... ...