servlets

Sending multiple parameters to servlets from either JSP or HTML

送分小仙女□ 提交于 2020-02-05 04:57:04
问题 I need to send a particular parameters to Servlet from JSP page. E.g: if I click on the Facebook icon on the web page, then I should send "facebook" as parameter to my Servlet and my Servlet will respond according to the parameter received from JSP file or HTML file. 回答1: Just wrap the icon in a link with a query string like so <a href="servleturl?name=facebook"><img src="facebook.png" /></a> In the doGet() method of the servlet just get and handle it as follows String name = request

org.hibernate.LazyInitializationException: could not initialize proxy -no Session

☆樱花仙子☆ 提交于 2020-02-03 09:57:33
问题 I am getting this bug when I run a test case(Junit) for spring application. I searched for this problem and I got the information that whenever a lazy initialization occurs and my application tries to get second level data while session is closed(object become detached) then this error occurs, we can't make initialization as EAGER as its performance issue. My testing class contains : @RunWith(SpringJUnit4ClassRunner.class) public class MyTestClass extends AbstractControllerTest { @Rule public

Global variable on servlet. is global for all sessions, or only for the current session? [duplicate]

痞子三分冷 提交于 2020-02-03 09:19:43
问题 This question already has answers here : How do servlets work? Instantiation, sessions, shared variables and multithreading (8 answers) Closed 3 years ago . I need to share information while the applicaiton is running; if I have: public class example extends HttpServlet { Object globalObject; doGet... doPost.... } A user is using the aplication through server and the object globalObject; if another user use the application, will share the object with the first user? 回答1: A user is using the

Global variable on servlet. is global for all sessions, or only for the current session? [duplicate]

孤人 提交于 2020-02-03 09:18:48
问题 This question already has answers here : How do servlets work? Instantiation, sessions, shared variables and multithreading (8 answers) Closed 3 years ago . I need to share information while the applicaiton is running; if I have: public class example extends HttpServlet { Object globalObject; doGet... doPost.... } A user is using the aplication through server and the object globalObject; if another user use the application, will share the object with the first user? 回答1: A user is using the

Global variable on servlet. is global for all sessions, or only for the current session? [duplicate]

守給你的承諾、 提交于 2020-02-03 09:18:04
问题 This question already has answers here : How do servlets work? Instantiation, sessions, shared variables and multithreading (8 answers) Closed 3 years ago . I need to share information while the applicaiton is running; if I have: public class example extends HttpServlet { Object globalObject; doGet... doPost.... } A user is using the aplication through server and the object globalObject; if another user use the application, will share the object with the first user? 回答1: A user is using the

java.lang.IllegalArgumentException: Filter mapping must specify either a <url-pattern> or a <servlet-name>

狂风中的少年 提交于 2020-02-03 04:37:05
问题 I've created very simple REST app with next web.xml: <context-param> <param-name>resteasy.scan</param-name> <param-value>true</param-value> </context-param> <listener> <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class> </listener> <servlet> <servlet-name>Resteasy</servlet-name> <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class> </servlet> <servlet-mapping> <servlet-name>Resteasy</servlet-name> <url-pattern>

<url-pattern> in filter mapping is not valid

这一生的挚爱 提交于 2020-02-02 11:57:46
问题 I have a @POST rest method and i want to make filter for it, so only the person who is logged in in the application to be able to have access to it. Here is my @POST method : @POST @Path("/buy") public Response buyTicket(@QueryParam("projectionId") String projectionId, @QueryParam("place") String place){ Projection projection = projectionDAO.findById(Long.parseLong(projectionId)); if(projection != null){ System.out.println(projection.getMovieTitle()); System.out.println(place); projectionDAO

Validating numbers with Servlets and JSP

淺唱寂寞╮ 提交于 2020-02-01 05:51:07
问题 I'm working on a small Servlets & JSP application while learning web development. I have a question regarding validations and passing values between jsp and servlets. I have a "Beer" class, with a "rating" property (of type double). The servlet that loads "edit.jsp" creates a Beer object and loads the current values from the DB. BeerDAO beerdao = new BeerDAO(); Beer beer = beerdao.getBeer(id); request.setAttribute("beer", beer); In the JSP, the object is displayed in the following manner: ...

Load balancing server, how can I implement it?

半城伤御伤魂 提交于 2020-02-01 04:51:42
问题 I googled for load balancing but the only thing I can find is the working theory, which at the moment, is the "easy" part for me. But zero examples of how to implement one. I have several questions pertaining load balancing: I have a domain (example.com) and I behind it I have a load balancing server (lets call it A ) which, according to the theory, will ask the client to close the connection with A, and connect to B, a sub-server and carry on the request with B. Will the client, in a web

Serving a zip file generated in server and stored in memory

拈花ヽ惹草 提交于 2020-01-30 11:01:05
问题 I need to generate a bunch of xml files with data from my java based web system, that represent a whole export of another system based in XML. Such system will accept this import later. My approach is to create all files in memory, then save each one as entries it to a zip also in memory, wich later is served to the client. The data flow is working perfectly, but somehow the output is a blank file. I think i got wrong the outpustream structure This is the part that i might be getting wrong: .