servlets

HttpServlet does not implement runnable or extend thread, why is it thread-able?

折月煮酒 提交于 2020-01-01 12:12:14
问题 For an object to be runnable, it needs to implement the Runnable interface or extend the Thread class, however, it does not seem that HttpServlet does any of these. How come HttpServlet can be threaded or have i mistaken? 回答1: The Servlet itself is not a thread. The container maintains one instance of the servlet class and each request (thread) calls the same servlet object. So the servlet instances is shared across threads. In pseudo code it may look like this: class ServerThread extends

Servlets with JavaBeans

女生的网名这么多〃 提交于 2020-01-01 12:02:10
问题 I have a set of three servlets, each one of them has a form with radio buttons that passes its values to the next servlet. What I am trying to do is to make a JavaBean class to use with the servlets and keep the state of them and the choices of the radio buttons while going from one servlet to another. Could anyone suggest some sample code for the JavaBean please? Here is some of the first servlet code: (The other two servlets have same code for other questions) protected void processRequest

Proper way to call servlet from Facelets?

徘徊边缘 提交于 2020-01-01 11:48:31
问题 What is the proper way to call a servlet from a facelets file using a form with submit button? Is there a particular form required? 回答1: Just use a plain HTML <form> instead of a JSF <h:form> . The JSF <h:form> sends by default a POST request to the URL of the current view ID and invokes by default the FacesServlet . It does not allow you to change the form action URL or method. A plain HTML <form> allows you to specify a different URL and, if necessary, also the method. The following kickoff

Proper way to call servlet from Facelets?

余生颓废 提交于 2020-01-01 11:48:21
问题 What is the proper way to call a servlet from a facelets file using a form with submit button? Is there a particular form required? 回答1: Just use a plain HTML <form> instead of a JSF <h:form> . The JSF <h:form> sends by default a POST request to the URL of the current view ID and invokes by default the FacesServlet . It does not allow you to change the form action URL or method. A plain HTML <form> allows you to specify a different URL and, if necessary, also the method. The following kickoff

Jython saying “No visible constructors for class”

二次信任 提交于 2020-01-01 10:59:30
问题 I have a jython servlet as part of a large application running in tomcat5. I tested a few Spring Framework classes and create the objects in the Jython servlet. When I try to create objects of classes in the application I catch an Exception message "No visible constructors for class". These java classes do have a public constructor class, such as: public SchoolImpl() { } I create the object in python: from com.dc.sports.entity import SchoolImpl ... school = SchoolImpl() What am I doing wrong?

web.xml order or filter and listener

霸气de小男生 提交于 2020-01-01 10:54:30
问题 For a Java EE web application, I have a listener that implements ServletRequestListener, and a Filter. Is there a way to specify at web.xml that the filter should be called before the listener? I've already tried declaring the filter and its mapping before the listener, but the listener is still executed before. Any idea? <filter> <filter-name>myfilter</filter-name> <filter-class>com.example.MyFilter</filter-class> </filter> <filter-mapping> <filter-name>myfilter</filter-name> <url-pattern>/*

web.xml order or filter and listener

心不动则不痛 提交于 2020-01-01 10:53:05
问题 For a Java EE web application, I have a listener that implements ServletRequestListener, and a Filter. Is there a way to specify at web.xml that the filter should be called before the listener? I've already tried declaring the filter and its mapping before the listener, but the listener is still executed before. Any idea? <filter> <filter-name>myfilter</filter-name> <filter-class>com.example.MyFilter</filter-class> </filter> <filter-mapping> <filter-name>myfilter</filter-name> <url-pattern>/*

JSP to Servlet Relation

六月ゝ 毕业季﹏ 提交于 2020-01-01 10:45:53
问题 There are many, many examples in books, and on the internet about how to use Servlets as JSPs. But I would like to know what the best way to go about using them, with a mind to good architecture. Should there be a one-to-one relation of Servlets to JSPs? Acting like ASP.NET "Code-Behind" pages? Or more like ASP.NET MVC, with a single Servlet controlling multiple actions, and forwarding to multiple views? This is a question regarding pure Java EE development. Please don't simply suggest

Use HTTPS only for certain pages in servlet based webapp

我只是一个虾纸丫 提交于 2020-01-01 09:23:15
问题 I have a servlet based webapp running on Tomcat 6 server. The URL scheme is HTTPS. The entire site is currently being served on HTTPS. But what I would really like to do is setup HTTPS only for certain operations like purchase and login. Is there any configuration in Tomcat that can help me do this easily? Are there any code changes required to persist session across HTTPS and HTTP? 回答1: Really, ideally, this is configured in your web app's web.xml file. You simply specify certain URLs that

Use HTTPS only for certain pages in servlet based webapp

試著忘記壹切 提交于 2020-01-01 09:22:39
问题 I have a servlet based webapp running on Tomcat 6 server. The URL scheme is HTTPS. The entire site is currently being served on HTTPS. But what I would really like to do is setup HTTPS only for certain operations like purchase and login. Is there any configuration in Tomcat that can help me do this easily? Are there any code changes required to persist session across HTTPS and HTTP? 回答1: Really, ideally, this is configured in your web app's web.xml file. You simply specify certain URLs that