servlets

How to create the Mongo database connection in context.xml in Java web project?

元气小坏坏 提交于 2021-01-29 22:14:43
问题 Although there are many proper tutorials to show how to connect relational database in Java, I really in doubt with the MongoDB mechanism working with Java. Normally people would create a connection in context.xml to interact with a relational database with JSP/servlet to do web project. However, with NoSQL database, I don't quite get any resources on how to perform this connection in a nice constructed way rather than many resources with framework lately and working seamlessly. If any

Datatable custom delete column

扶醉桌前 提交于 2021-01-29 17:55:11
问题 I have datatable with multiple movies(rows), at the end of each row, there is custom column for delete. Here is my datatable: HTML <table id="moviesTable1" class="table table-striped table-bordered"> <thead> <tr> <th>Title</th> <th>Duration</th> <th>Distributor</th> <th>Origin country</th> <th>Year of production</th> <th></th> </tr> </thead> <tbody id="moviesTbody"> </tbody> </table> jquery (I also have add movie, getAll which works fine) var MoviesManager = { getAll : function() { $.get(

Serve files from a folder different of context directory in a servlet container

久未见 提交于 2021-01-29 17:50:29
问题 I got a situation that I must serve files from different folders then the one of the context my web app is running. As an example, suppose my web app is running in a servlet context on "/opt/tomcat/webapps/ROOT/" and I must serve files existent in "/opt/my_other_folder/". These folders can be changed in runtime by the client, so I can't simply add a new context pointing to these directories. I would like a solution that I wouldn't have to rewrite a web server only for that. Also, the product

How to share data between a JSP and servlet [duplicate]

旧巷老猫 提交于 2021-01-29 15:00:32
问题 This question already has answers here : Show JDBC ResultSet in HTML in JSP page using MVC and DAO pattern (5 answers) Passing an object from JSP page back to Servlet (3 answers) How can I store state for an individual browser tab/window? (2 answers) Closed 11 months ago . I am developing a website with servlets and JSP.I want to know how to share data between a servlet and JSP as while searching I noticed that the getSession() method has been deprecated and currently I cannot add data to

java.lang.IllegalStateException: :Cannot initialize context because there is already a root application context present

我的梦境 提交于 2021-01-29 13:08:39
问题 I am trying to migrate application deployed on weblogic 12 to tomcat 9 and while doing so I am facing following exception java.lang.IllegalStateException: Cannot initialize context because there is already a root application context present - check whether you have multiple ContextLoader* definitions in your web.xml! content of my web.xml is as follows <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee"

Redirect to <error-page> on session timeout

[亡魂溺海] 提交于 2021-01-29 11:21:19
问题 I have a standard J2EE web-application running on WebLogic server. I want to handle a session timeout through the meta-data setup in web.xml. I tried to use the following setting <error-page> <error-code>408</error-code> <location>/jsp/testErrorPage.jsp</location> </error-page> However it didn't work. 回答1: Below is the explanation for 408 request timeout, The Web server (running the Web site) thinks that there has been too long an interval of time between the establishment of an IP connection

How to get a user clinet/Remote port in java DynamoHttpServletRequest

我怕爱的太早我们不能终老 提交于 2021-01-29 09:11:13
问题 I try to get a client port for some security purpose. The Remote Port is change for each and every DynamoHttpServlet Request and Response. I need a constant Remote port look like session. When user enter into the site that time Remote port was generated but this generated port destroy only when user leave the site until i need the same port in each and every request. Is there any possibilities ? 来源: https://stackoverflow.com/questions/64641731/how-to-get-a-user-clinet-remote-port-in-java

Retrieve Image from Database and display in another jsp page [duplicate]

妖精的绣舞 提交于 2021-01-29 08:44:43
问题 This question already has answers here : How to retrieve and display images from a database in a JSP page? (5 answers) Closed 1 year ago . I am trying to retrieve multiple images from database and display those images in another JSP page. First, I tried single image to display in particular JSP page, I retrieved but the display is showing as file type, I want to display that image in particular JSP page. I am using MySQL database. my servlet code: import java.io.IOException; import java.sql

Why does <jsp:getProperty> need <jsp:useBean>, but EL doesn't?

若如初见. 提交于 2021-01-29 07:10:03
问题 I have servlet with following code: protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Person p = new Person("Mike"); req.setAttribute("person", p); RequestDispatcher view = req.getRequestDispatcher("/result.jsp"); view.forward(req, resp); } I have two choices for printing person's name inside result.jsp . Using <jsp:getProperty> or Expression language . Simple EL code: <!DOCTYPE html> <html><body> Welcome ${person.name} </body></html

How include servlet output to jsp file

给你一囗甜甜゛ 提交于 2021-01-29 06:10:21
问题 In my web application I have a main page that contain some information. This page is created by servlet and corresponding jsp file. Almost all other pages in my web application must contain the same information as main page plus some addition information. I don't want dublicate code, so I want to use output of main servlet in other jsp files. Below is a simple example of what I try to accomplish. This is web.xml file: <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.1" xmlns="http:/