servlets

How can I pass an ArrayList from one servlet another?

牧云@^-^@ 提交于 2019-12-24 23:48:16
问题 I have already sent arraylist1 from one servlet to another. It works. Now I want to pass arraylist2 to another jsp/servlet, but I get an error: java.util.nullPointer Exception . How can I resolve this? 回答1: RequestDispatcher disp2 = request.getRequestDispatcher("NewServlet.java"); should be RequestDispatcher disp2 = request.getRequestDispatcher(pathToYourServlet); The path is the end of the page adress: http://localhost/yourApp/ pathToYourServlet 回答2: You need to look at the full stack trace

spring-mvc can not decode chinese characters

断了今生、忘了曾经 提交于 2019-12-24 23:48:15
问题 I have read this jsp page encoding problem and this Save Chinese characters with Spring-MVC / Java I had the following code fragment in web.xml since the start of my project and it seems to injected correctly: <!-- Reads request input using UTF-8 encoding --> <filter> <filter-name>characterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param>

Is it possible to use a different Spring Security AuthenticationProvider in different servlets, same WAR?

杀马特。学长 韩版系。学妹 提交于 2019-12-24 22:28:21
问题 I have a single WAR that runs two servlets. One provides AMF remoting to Flex clients and other SOAP/HTTP to web service clients. I currently have Spring Security configured to authenticate the Flex clients using DaoAuthenticationProvider. However, I'd like to use a different authentication provide for the SOAP/HTTP. Possibly basic authentication or some other form. Is it possible? or do I need two WARs? 回答1: I think you'll run into problems issues with instantiating two security filter

isReady() returns true in closed state - why?

前提是你 提交于 2019-12-24 21:53:16
问题 ServletOutputStream.isReady() javadoc says the following: Returns: true if a write to this ServletOutputStream will succeed, otherwise returns false. In spite of that Jetty's ServletOutputStream implementation, HttpOutput seems to behave rather confusing in the case when the stream is in CLOSED state. It returns true : case CLOSED: return true; Source: HttpOutput.java:1011. Furthermore, all three write methods in HttpOutput throws EofException when it's CLOSED : case CLOSED: throw new

vaadin generated page doesnt show any component

[亡魂溺海] 提交于 2019-12-24 21:12:26
问题 I have a problem at vaadin framework in general. I created a class extends vaadin application(MyFirst), after that I created a custom component with vaadin visual designer(MyFormApp). I did instantiate the custom component MyFormApp, and I added it to the main window of the MyFirst. After deploying the app, the page generated by vaadin does not show any component. My code : /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.example

How to reduce the usage of IF - ELSE by reflection ? Can I get the code example

情到浓时终转凉″ 提交于 2019-12-24 21:02:53
问题 I was trying to use reflection for the code of PizzaFactory Class so that I can remove the if else condition and make my code more dynamic. But I am not able to figure out how. Pizza.java package PizzaTrail; import java.util.List; //this is the main abstract factory which will be extended by the concrete factory public abstract class Pizza { public abstract List fetchIngredients(String Type); } PizzaFactory.java package PizzaTrail; import java.util.List; //this is the concrete factory public

How does spring security work on a Servlet

北战南征 提交于 2019-12-24 19:23:30
问题 I have a java that calls a Servlet: public class UserServlet extends HttpServlet { @Autowired private UserService userService; @Override protected void service(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { userService.checkUser(); userService.doSomethingRestricted(); } @Override public void init(final ServletConfig config) throws ServletException { SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);

Using JSP Bean in a Servlet

假装没事ソ 提交于 2019-12-24 19:11:26
问题 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 and it's giving me a different value for both pages, so I can't access the bean. Any ideas? 回答1: Yes, you can obtain it as attribute from the session by the id as

How to make a XMPP client in a container like tomcat?

こ雲淡風輕ζ 提交于 2019-12-24 19:09:52
问题 I need to login, receive and send some messages over XMMP with a servlet loaded on tomcat container. I would like to know if there is any implementation already of this situation ? thx for ur time :) 回答1: I've found smack to be the best available java library for XMPP. It is however, far from perfect for server side development. In particular you need to think about your clustering early as smack connections hold alot of state. The api itself is very nice however, it's pretty trivial to

How do you output a view file as an ajax response in Java?

这一生的挚爱 提交于 2019-12-24 18:45:05
问题 I am a PHP developer but am transitioning to Java. (very new to Java at this point) Is there a way to make an ajax call to a Servlet, and respond with the output of a separate .jsp file (as opposed to html or json created directly in the Servlet)? Here is an example of what is common practice w/ Zend Framework, which is what I would like to do with Java if possible: public function myAjaxCallAction(){ $this->view->someVar = 'whatever'; $this->view->hello = 'world'; $output = $this->view-