servlets

Can servlet attribute names contain a hyphen -?

不打扰是莪最后的温柔 提交于 2020-03-16 08:17:07
问题 Can servlet attribute names contain a hyphen - ? Because, I tried to retrieve the attributes from the request set in the doPost in my servlet, but the result is not what I'm looking for. In my servlet I have this : String X_USER = request.getParameter("X-User"); request.setAttribute("X-User", X_USER); String YYYY_YYYY = request.getParameter("Y_CODE"); request.setAttribute("Y-Code", YYYY_YYYY); In my JSP where I want to show these attributes I do this: <li>${X-User}</li> <li>${Y-Code}</li> The

File listing from google cloud storage

*爱你&永不变心* 提交于 2020-03-01 01:49:05
问题 For a project I'm doing, I will have files stored in Google's Cloud Storage and am building a web app to interface to those files. I would like my app to show a list of the files (or objects may be the appropriate name) stored in my bucket. I'm completely new to web development and google apis. I've been researching how to do this and have found this bit of code... Storage storage = new Storage(httpTransport, jsonFactory, credential); ObjectsList list = storage.objects().list("bucket-name")

how to message from servlet and display in jsp

ぃ、小莉子 提交于 2020-02-26 08:12:40
问题 I'm trying to do something that looks small but it's failing. I'm trying to send a response message back to a jsp when login fails but not being able. As of now I can only redirect back to the jsp but cannot display a message from the servlet on it. This is the servlet part of the redirection: if (count > 0) { res.sendRedirect("adminHome.jsp"); } else { res.sendRedirect("index.jsp"); } I tried to print a message using PrintWriter and the redirect but failed because I couldn't get how to

how to message from servlet and display in jsp

人盡茶涼 提交于 2020-02-26 08:12:22
问题 I'm trying to do something that looks small but it's failing. I'm trying to send a response message back to a jsp when login fails but not being able. As of now I can only redirect back to the jsp but cannot display a message from the servlet on it. This is the servlet part of the redirection: if (count > 0) { res.sendRedirect("adminHome.jsp"); } else { res.sendRedirect("index.jsp"); } I tried to print a message using PrintWriter and the redirect but failed because I couldn't get how to

Invoke the doGet Servlet method from java class

一曲冷凌霜 提交于 2020-02-25 08:51:32
问题 I have a scheduled job class, implements the Quartz Job class, from which I want to invoke a Servlet class that updates a flag in a DB table and then it sends emails to an appropriate emailing list. I get a java.net.ConnectException . Though the servlet is properly invoked by either entering its URL in the browser or by JavaScript in a JSP page. My Java class is the following: public class ExpirationJob implements Job { org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(

Invoke the doGet Servlet method from java class

我只是一个虾纸丫 提交于 2020-02-25 08:51:15
问题 I have a scheduled job class, implements the Quartz Job class, from which I want to invoke a Servlet class that updates a flag in a DB table and then it sends emails to an appropriate emailing list. I get a java.net.ConnectException . Though the servlet is properly invoked by either entering its URL in the browser or by JavaScript in a JSP page. My Java class is the following: public class ExpirationJob implements Job { org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(

servlet is not connecting to mysql database

我们两清 提交于 2020-02-25 07:52:54
问题 I'm getting a error when trying to connect to a mysql database. I have an DatabaseAccess.java: import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; @SuppressWarnings("serial") public class DatabaseAccess extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Set response

Convert String dd/MM/yyyy date into java.sql.date yyyy-MM-dd

给你一囗甜甜゛ 提交于 2020-02-25 07:13:31
问题 I am using the below method to do the described conversion. But the java.sql.Date method is deprecated. So, is their any harm in using this method? As the statements below are working fine. (Retrieving value of date as string in servlet from session and then storing the date in MySQL.) String f33_ = (String) session.getAttribute("sf33"); java.sql.Date f33 = new java.sql.Date(Integer.parseInt(f33_.substring(6, 10))- 1900, Integer.parseInt(f33_.substring(3, 5))-1,Integer.parseInt(f33_.substring

When does the ServletContext return a null RequestDispatcher?

て烟熏妆下的殇ゞ 提交于 2020-02-22 04:11:21
问题 The api for ServletContext#getRequestDispatcher() says: This method returns null if the ServletContext cannot return a RequestDispatcher. and Returns: a RequestDispatcher object that acts as a wrapper for the resource at the specified path, or null if the ServletContext cannot return a RequestDispatcher For what reason would the ServletContext not be able to return a RequestDispatcher? At first I figured it would be if an invalid path was passed but that doesn't return null, it results in a

When does the ServletContext return a null RequestDispatcher?

落爺英雄遲暮 提交于 2020-02-22 04:10:57
问题 The api for ServletContext#getRequestDispatcher() says: This method returns null if the ServletContext cannot return a RequestDispatcher. and Returns: a RequestDispatcher object that acts as a wrapper for the resource at the specified path, or null if the ServletContext cannot return a RequestDispatcher For what reason would the ServletContext not be able to return a RequestDispatcher? At first I figured it would be if an invalid path was passed but that doesn't return null, it results in a