servletconfig

Error getting file name using getServletConfig

僤鯓⒐⒋嵵緔 提交于 2019-12-20 04:37:11
问题 I am using JasperReport for generation reports in Java Web Application. I have a following line to get report file. JasperReport report = (JasperReport) JRLoader.loadObject(getServletConfig().getServletContext().getRealPath("\rpts\report1.jasper")); But when I try using above line I am getting FileNotFoundException . But when I try using following line, program executes successfully. JasperReport report = (JasperReport) JRLoader.loadObject(getServletConfig().getServletContext().getRealPath("/

Unable to get servletcontext path in jsf

一个人想着一个人 提交于 2019-12-20 03:29:09
问题 I have written a liferay richfaces portlet. But iam not able to get the css path or images in the web-inf folder. My portlet config is <portlet> <portlet-name>testLR6_PB3_RF4</portlet-name> <instanceable>true</instanceable> <render-weight>1</render-weight> <ajaxable>true</ajaxable> <header-portlet-css>/resources/css/style.css</header-portlet-css> <header-portlet-javascript>/js/eims.js</header-portlet-javascript> <footer-portlet-javascript>/js/fileupload.js</footer-portlet-javascript> <

Servlet 3.0 annotations <welcome-file>

梦想的初衷 提交于 2019-12-18 06:02:22
问题 Is it possible to set welcome-file tag from standard web.xml file by servlet 3.0 annotation ? <welcome-file-list> <welcome-file>PageName.html</welcome-file> </welcome-file-list> 回答1: No, there is not such annotation at the moment. Servlet 3.0 annotations are InitParam, ServletFilter, WebServlet, WebServletContextListener, there's nothin for the welcome files in there. 来源: https://stackoverflow.com/questions/2540549/servlet-3-0-annotations-welcome-file

How to get ServeletConfig in Jersey Provider?

老子叫甜甜 提交于 2019-12-12 04:44:08
问题 So I have a Jersey REST service and I need to get access to a ServletConfig so that I can pull a param out of the web.xml. I can use @Context to wire one in but I don't think it will get me the params I need. Only the ones in the ServletContext. Any ideas? I'm new to Jersey and this Provider isn't a Servelet. Perhaps I should start with trying to retrieve the servelet? 回答1: @Context: annotation can be used to inject the following classes HttpServletRequest HttpServletResponse ServletContext

ServletConfig对象学习

a 夏天 提交于 2019-12-10 14:56:08
1, 在 Servlet 的配置文件中,可以使用一个或多个 <init-param> 标签为 servlet 配置一些初始化参数。 当 servlet 配置了初始化参数后, web 容器在创建 servlet 实例对象时,会自动将这些初始化参数封装到 ServletConfig 对象中,并在调用 servlet 的 init 方法时,将 ServletConfig 对象传递给 servlet 。进而,程序员通过 ServletConfig 对象就可以得到当前 servlet 的初始化参数信息 。 代码:(为servlet配置初始化参数) <servlet> <servlet-name>ServletDemo8</servlet-name> <servlet-class>cn.yujian.ServletDemo8</servlet-class> <init-param> <param-name>name</param-name> <param-value>xxxx</param-value> </init-param> <init-param> <param-name>charset</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>url</param-name

Servlet中ServletConfig和ServletContext漫谈

别来无恙 提交于 2019-12-04 21:50:08
Servlet的API有很多,这里只谈谈两个Servlet对象:ServletConfig对象和ServletContext对象。 1. ServletConfig对象 在Servlet的配置文件中,可以使用一个或多个<init-param>标签为servlet配置一些初始化参数,当Servlet配置了初始化参数后,web容器在创建servlet实例对象时,会自动将这些参数封装到ServletConfig对象中,并在调用Servlet的init方法时,将ServletConfig对象传递给Servlet。进而,程序员通过ServletConfig对象就可以得到当前Servlet的初始化参数信息。该对象的getInitParameter(String name)用来获得指定参数名的参数值,getInitParameterNames()用来获得所有参数名,我们测试一下: 在test工程的src下新建一个包servletConfig,然后新建一个ServletConfigDemo1类,在配置文件里进行如下配置: <servlet> <servlet-name>ServletConfigDemo1</servlet-name> <servlet-class>servletConfig.ServletConfigDemo1</servlet-class> <init-param>

Error getting file name using getServletConfig

前提是你 提交于 2019-12-02 07:08:47
I am using JasperReport for generation reports in Java Web Application. I have a following line to get report file. JasperReport report = (JasperReport) JRLoader.loadObject(getServletConfig().getServletContext().getRealPath("\rpts\report1.jasper")); But when I try using above line I am getting FileNotFoundException . But when I try using following line, program executes successfully. JasperReport report = (JasperReport) JRLoader.loadObject(getServletConfig().getServletContext().getRealPath("//rpts//report1.jasper")); So, I want to know what is the problem with first line? Thanks in advance...

Unable to get servletcontext path in jsf

徘徊边缘 提交于 2019-12-02 01:53:45
I have written a liferay richfaces portlet. But iam not able to get the css path or images in the web-inf folder. My portlet config is <portlet> <portlet-name>testLR6_PB3_RF4</portlet-name> <instanceable>true</instanceable> <render-weight>1</render-weight> <ajaxable>true</ajaxable> <header-portlet-css>/resources/css/style.css</header-portlet-css> <header-portlet-javascript>/js/eims.js</header-portlet-javascript> <footer-portlet-javascript>/js/fileupload.js</footer-portlet-javascript> </portlet> and in my jsf page <link href="${facesContext.externalContext.requestContextPath}/resources/css

Servlet 3.0 annotations <welcome-file>

允我心安 提交于 2019-11-29 10:41:48
Is it possible to set welcome-file tag from standard web.xml file by servlet 3.0 annotation ? <welcome-file-list> <welcome-file>PageName.html</welcome-file> </welcome-file-list> No, there is not such annotation at the moment. Servlet 3.0 annotations are InitParam, ServletFilter, WebServlet, WebServletContextListener, there's nothin for the welcome files in there. 来源: https://stackoverflow.com/questions/2540549/servlet-3-0-annotations-welcome-file

ServletConfig vs ServletContext

孤人 提交于 2019-11-28 13:54:28
问题 What is the difference between ServletConfig and ServletContext interface? 回答1: The ServletConfig parameters are specified for a particular servlet and are unknown to other servlets. It is used for intializing purposes. The ServletContext parameters are specified for an entire application outside of any particular servlet and are available to all the servlets within that application. It is application scoped and thus globally accessible across the pages. 回答2: Source : Difference between