jsp

Unable to compile class for JSP:Tomcat 9

匆匆过客 提交于 2021-01-29 10:32:53
问题 I'm using the latest TomCat version and I've recently installed Eclipse Java EE version so it's also the latest version. Btw I do have the latest version of JAVA SE (JDK). This is my class: package jsp.demo; public class ClassForJSP { public static String lowerCase(String data) { return data.toLowerCase(); } } So this is my really simple jsp code: <%@page import="jsp.demo.ClassForJSP"%> <html> <body> Let's make THIS STATEMENT lower case: <%= ClassForJSP.lowerCase("THIS STATEMENT") %> </body>

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

What are different ways to access variables with OGNL in Struts 2

女生的网名这么多〃 提交于 2021-01-29 07:02:49
问题 I am working now in a Struts2 project which uses OGNL. I see three different ways to access data in JSP using OGNL. value1 ="previousList" value2 = "#previousList" value3 = "%{previousList}" What these will do and are there other ways to access data from OGNL? 回答1: The value stack which is an implementation of ValueStack has two methods push and set . The first method pushes the variable to the stack, but the second sets in to the value stack's context. If the variable in the value stack's

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:/

Hide a HTML button based on a if-condition

拈花ヽ惹草 提交于 2021-01-29 05:34:24
问题 I have a JSP page which includes a button called "Download".I want to hide this button based on a if-condition. The Download button is meant to generate and download PDF onclick of it. I have a List that is being fetched from the Controller and if this list is empty, I want to hide the "Download" button on the JSP page. This is my button, <button type="button" class="btn bg-red waves-effect" onclick="ExportPdf()">Download</button> I want to hide the button if the List is empty. 回答1: Display

Google App Engine JSP

妖精的绣舞 提交于 2021-01-29 05:04:39
问题 I have created a Google App Engine project, but because of some SEO concerns I want to change one of my pages from HTML (+ JQuery) to a JSP that gets rendered on the server This page is the index.html file, how can I make it work as a JSP without renaming it (I don't want the user to go to index.jsp, but instead treat index.html as a JSP page) I've tried adding this to my web.xml, but it doesn't seem to work <servlet> <servlet-name>main</servlet-name> <jsp-file>/index.html</jsp-file> (or

jdbc to MYSQL error: “table airportdetails doesn't exist”

你。 提交于 2021-01-29 04:59:22
问题 I am trying to connect to a MySQL database from a jsp page using jdbc in the backend. I have the following code: public static void insertIntoDatabase(String code,String name,String temp,String hum,String del) { Connection con = null; if (del.length() == 0) { del="no data"; } name = name.replaceAll("\\(.+?\\)", ""); name = name.replaceAll(" ", "_"); del = del.replaceAll(" ", "_"); System.out.println("del "+del); String url = "jdbc:mysql://localhost:3306/test"; try { Class.forName("com.mysql

session().getAttribute is returning null

时光总嘲笑我的痴心妄想 提交于 2021-01-29 04:35:51
问题 I have a servlet which calls a jsp page. In the servlet I am retrieving the username provided at the login correctly. But after setting the same in session, when i access the called jsp page, its returning null. Servlet Code: public class AdminServlet extends HttpServlet { /** * */ private static final long serialVersionUID = -4244742541587179390L; public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String userName = request

how does jsp:useBean scope attribute work?

放肆的年华 提交于 2021-01-29 03:28:46
问题 I am trying to understand how exactly scope attribute in jsp:useBean JSP action tag works. In my understanding scope is used to indicate where the bean is located (request,session,application etc.), but after some testing I came across an interesting situation where it's not the case, please consider the following JSP code (I am using scriplets here just for the sake of simplicity): <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import=