static 1 « Development « JSP-Servlet Q&A





1. Servlet for serving static content    stackoverflow.com

I deploy a webapp on two different containers (Tomcat and Jetty), but their default servlets for serving the static content have a different way of handling the URL structure I want ...

2. Servlets and static content with JRuby embedded jetty    stackoverflow.com

I would like to serve servlets and static content with jetty embedded in JRuby. I tried this:

server = Server.new(8080)
context = Context.new(server, '/', 0)

context_static = Context.new(server, '/static', 0)
context_static.setHandler(ResourceHandler.new)
context_static.setResourceBase('./')
context_static.setContextPath('/static')

servlet = Servlet.new()
holder = ServletHolder.new(servlet)
context.addServlet(holder, ...

3. Making Velocity Template Object Static    stackoverflow.com

Is it good to make Velocity Template Object Static? The situation is im going to use this object in (Servlet) multi user environment populating different data for each user-request with same template. ...

4. Static Access to HashMap/Array?    stackoverflow.com

Here's an example of a static method that is used in a web application. As you can see, the String[] allergensArr gets insantiated each time that this method ...

5. Static Classes in Servlet    stackoverflow.com

I make static classes in servlet, these classes are controllers for web pages. Requests are redirected to controllers by controller urls that are in static HashMap that contains all controllers. Are ...

6. How to configure routing for a java web app    stackoverflow.com

Is there an easy way to rout all requests (except a few specific cases) for url "mysite/" to path "mysite/index.html?" Is it possible to do it only by editing web.xml file?

7. Optimized throughput of static content from app server    stackoverflow.com

I am building a small web application that primarily needs to serve up protected static content -- some flash (.swf) files > 20MB -- from an application server (Websphere) that is ...

8. Jsp declaration element    stackoverflow.com

<%!
class father {
static int s = 0;
}
%>

<%
father f1 = new father();
father f2 = new father();
f1.s++;
out.println(f2.s); // It must print "1"
%>
When I run the file, I got this error. Can anybody explain? "The ...

9. Using static strings to define input field names in JSPs - good idea or not?    stackoverflow.com

I've just be asked to work on a large portal project and have been looking through the established code. I keep finding this in the jsps:

<input class="portlet-form-button"
    name="<%=ModifyUserProfile.FORM_FIRST_TIME_LOGIN_SUBMIT%>" ...





10. Include static file in JSP with variable filename on WebSphere 6    stackoverflow.com

I'm struggling with including a static file into my JSPs on Websphere 6.0.2.17. I tried this:

<% final String MY_DIR = ResourceBundle.getBundle("mybundle").getString("props.pages.wcm"); %>
<% final String page = ResourceBundle.getBundle("mybundle").getString("page"); %>
<% final String inc ...

11. Questions about serving static files from a servlet    stackoverflow.com

I'm very new to servlets. I'd like to serve some static files, some css and some javascript. Here's what I got so far: In web.xml:

<servlet>
    <description></description>
    ...

12. Servlets, development, and a CDN for static files    stackoverflow.com

I'm working on a Java site (jQuery, Wicket, Maven, Spring, Hibernate) and we have just started using a CDN to serve static files on our production server. We use a placeholder ...

13. Java Servlet Static Class    stackoverflow.com

I'm learning J2EE and migrating my AP.NET project into Java. IN Asp.NET I have Helper class which has methods like encode decode, convert, etc... In ASP.NET I'm initiating public static class Helper ...

14. Static method from servlet    stackoverflow.com

I'm writing my Servlet application and would like to use the following static method which will multiply x and y.

public class Helper {
    private Helper() {
   ...

15. Static Variables Behaviour in a Java Servlet    stackoverflow.com

I am developing a java servlet that while running, starts different objects methods in new threads. Those threads should access a variable that describes the specific servlet instance, say jobId. For ...

16. how can i get static field in JSP file?    stackoverflow.com

i set a static field in jsp page a.jsp:

<%!
public static int A=123;
%>
how can i get this static variable A in other JSP file? (do not include a.jsp) it is possible? thanks for help ...





17. Reference static fields in JSP without using scriptlets    stackoverflow.com

Possible Duplicate:
Reference interface constant from EL
So I have a JSP that currently has no scriptlets in it, i.e. there are no occurrences of "<%" ...

18. Serve a static image file from the filesystem in a servlet?    stackoverflow.com

How do I serve an image file in the filesystem from a servlet?

19. where put images files in big multimodules web app    stackoverflow.com

I have big WEB application (jsp). What is the best way to put images files? Where to put images files in multi modules web application? I have many images so I ...

20. what is meant by that in a servlet (private static final long serialVersionUID = 1L)?    stackoverflow.com

Can any one tell me that what is the meaning of

private static final long serialVersionUID = 1L 

21. How to access - with EL - an static field of a imported object    stackoverflow.com

Possible Duplicate:
How to reference constants in EL?
Let's say I have a class with a static final int field, and I have imported a class ...

22. accessing static field of class from jsp    stackoverflow.com

In a web app, my servlet is printing html as below

protected void doGet( HttpServletRequest request, HttpServletResponse response )
            throws ServletException, ...

23. EL: how to print static variables?    stackoverflow.com

I have the following JSP page:

<%@taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
test #1: value of PI is <c:out value="${java.lang.Math.PI}" />.
test #2: value of PI is ${java.lang.Math.PI}.
test #3: value of PI is <%= java.lang.Math.PI %>.
Somehow, only ...

24. JSP page to static HTML using Java code    stackoverflow.com

How do I save a dynamic JSP page to a static HTML page using Java code? I want to save JSP output to an HTML page and save it on the local ...

25. How to allow access to static content when having default servlet    stackoverflow.com

I map all requests to /* to a specific servlet. My static content is hidden by this configuration. How can i allow access to specific files (such as crossdomain.xml)?

26. How can I initialize this semaphore    stackoverflow.com

I asked this question about multithreading in servlet, and many people suggest using a static variable. If I set a static variable and I need to initialize it. For example ...

27. How to call a static method in JSP/EL?    stackoverflow.com

I'm new to JSP. I tried connecting MySQL and my JSP pages and it works fine. But here is what I needed to do. I have a table attribute called "balance". Retrieve ...

28. How to change location of static file in WAR archive?    stackoverflow.com

By default static files are located in WEB-INF directory (accessible as /images/logo.png):

foo.war
  WEB-INF
    web.xml
    images
      logo.png
I want to change ...

29. What's the best way to add dynamic content into a static html page fom a servlet?    stackoverflow.com

I've written up a few servlets to mimick the handling of login requests in order to more understand how this communication works, aswell as how the creation and managing of cookies ...

30. Are static members shared across applications in a JEE compliant servlet container?    stackoverflow.com

If I have a Servlet class, and this class is used in two applications - are static members of shared across both applications? Is this behaviour specified by JEE or container specific? ...

31. Generating Static HTML App from a JSP site    stackoverflow.com

I've a Java web app, using JSP+Struts2+Spring and Dojox.mobile. Is there any best practice to turn the web app into a static html app ? I've to package it at the ...

32. Servlet Performance: Generate Static Content Dynamically?    stackoverflow.com

I have a web-page with content, which has to be generated. However, the generation could happen up-front, it's basically not more than generating multiple versions of the same file. I.e. I ...

33. Best way to handle large amounts of static text, images when creating pdf using iText    stackoverflow.com

We are going to use iText to create a large report. There will be a lot of static text and images that will be the same for every report. We will ...

34. why EL functions in jsp must be declared as static?    stackoverflow.com

I am reading some JSP text regarding EL user-defined functions, and the author said these kinds of functions must be declared static and gave no other explanation. I have tried to ...

35. Static includes in Portlet jsp    coderanch.com

36. using huge static data in JSP    coderanch.com

Hi There, I am facing the following problem, I have to share huge data around 1.5 MB across JPS. It is fetched from DAO (SOAP service) and stored in HashMap as name value pairs. Note that this data will be refreshed every two day so it is sought of static and dyanmic as well. I am thinking Option 1: I would ...

37. JSP + static variables    coderanch.com

Yes, you can declare static variables in JSP, but the value of doing so is dubiuos. The issue was that his method was declared inside JSP declaration tags ( <%! %> ) which made it a method of the servlet class. But his variable was defined inside scriptlet tags ( <% %> ) which meant the variable was scoped inside the ...

38. problem with jsp accessing a servlets static methods    coderanch.com

I am getting this message when trying to access a servlets static method in a jsp. error: File C:\Jakarta\tomcat\webapps\myApp\Web-Inf\classes\JspUtils.java does not contain type JspUtils as expected. Please adjust the class path so that the file does not appear in the unnamed package. I am not sure what this means as there is no package declaration in the JspUtils class. I had ...

39. static variables ?    coderanch.com

40. Static method and classes    coderanch.com

41. accessing non-static methods from JSP    coderanch.com

42. static results in JSP pages    coderanch.com

Dear all, I am a new member of the group.I have to build an application using JSP. I created the .JSP files and put them in the tomcat directory jsp-examples\mydirectory\.. also i created my login.java file and put that at WEB-INF\classes directory. Now the problem is when i called the TOMCAT i cud execute and link my JSP files with the ...

43. Reusing a "mostly" static chunk of HTML    coderanch.com

45. Dynamic vs Static include    coderanch.com

46. jsp static include - no joy    coderanch.com

Hey guys, wonder if you can help with this small problem... trying to include a jspf frag in my main jsp (as a header), but it doesn't appear. In my web-app structure, I have placed files in the following places:- The jspf fragment (header) -> Gallery/WebRoot/WEB-INF/jspf/Header.jspf The image called by the fragment -> Gallery/WebRoot/images/logo.gif The main jsp that is trying to ...

47. static fields and EL    coderanch.com

48. JSP--Java class's static variable    coderanch.com

hi all, I have strange problem with JSP. I am using a static variable of a Java Class in JSP. If I change the variable value in Java class, compile it with out changing/re-compiling the JSP, that change is not getting effected. But when I re-compile JSP, the Java class's changes are getting affected. Can anybody tell me what happens when ...

51. static and dynamic includes    coderanch.com

52. application and static content    coderanch.com

53. static variables    coderanch.com

54. Static methods and variable in jsp    coderanch.com

Yes it is possible. No, is is not advised. Why put java code in a JSP? If you have a static method that you want to declare, create a java class for it and declare it there. There is absolutely no motivation to put them into a JSP, whereas by putting it into a java class, you can get compile time ...

55. decalring static varibles in JSP    coderanch.com

56. static content access    coderanch.com

59. Static Block in JSPs    coderanch.com

62. MDBs and static HibernateUtil/Configuration    coderanch.com

In the onMessage() method of a Message-Driven Bean there is code that uses a HibernateUtil class to get a reference to a SessionFactory. The code for creating the SessionFacotry is implemented in a static initialization block in the HibernateUtil class. sessionFactory = new Configuration().configure().buildSessionFactory(); This static initialization block executes when the class is loaded in the application server's JVM. And the ...

63. Static data in Servlets    coderanch.com

64. Static data updation in Servlet as well as in Java Application at same time    coderanch.com

Hello, I m facing a problem in updating a static data member of some class in servlet Context as well as in simple Java Application at the same time . Problem is that Servlet is not considering the static Context of the object and treat it as a seperate instance. How can i update a static data member of some class ...

65. Static Include files in servlet    coderanch.com

66. Static methods and JSP    coderanch.com

67. Can i invoke a static method from JSP    coderanch.com

68. Reading static files with servlets    coderanch.com

69. static vars vs. servlet context    coderanch.com

Bill, I guess I'm not sure how using static variables would make the base servlet (and it's children) any more complex. I'm working on a framework where there are a number of utility and helper classes that perform various services such as logging, JDBC connections, security, and app configuration. What I'm doing is using a single servlet (I call it AppInitializer) ...

70. Servlets - static methods - User unique data - The Good, Bad & Ugly    coderanch.com

Hi folks, I teach Java and have one of those classes right now that REALLY need to get down to the absolute whys, whens, & hows... I will say they are a great bunch because they are ALWAYS keeping me on my toes & challenging me....BUT I seem to have hit a major wall trying to explain to them why static ...

72. static methods and servlets    coderanch.com

73. Servlets and Static variables...    coderanch.com

74. Static & Instance in Servlet    coderanch.com

75. Instance Vs Static in Servlet    coderanch.com

76. Static method and Servlet    coderanch.com

77. static variable in servlet - when can we use?    coderanch.com

There is one "gotcha" to look out for if you're going to declare static variables in a servlet app. It's a bit of a fringe case but is probably worth mentioning. In containers like Tomcat, each webapp has it's own classloader for it's servlets. This means static variables declared in classes within one app will be isolated from other apps running ...

78. static variable in a servlet    coderanch.com

80. static variables and methods in servlet    coderanch.com

First, static variables and static methods are two different topics. Unless you have a real good reason to use them and you really know what you're doing, I'd avoid using static variables in web apps. Doing so can lead to some confusing behavior. [ September 29, 2006: Message edited by: Ben Souther ]

81. Servlet design - static methods    coderanch.com

82. Serving static assets from a servlet    coderanch.com

Hi- I'm putting together a little mini-framework for a project I'm doing. I'm using a front controller servlet to process all requests (/* ) . Is there an easy way to serve static assets (images, css, some html). Basically, I just want to be able to identify the request as a static asset, and say "just do what you normally would ...

85. Fundamental Doubt about static methods    coderanch.com

86. Error while loading static content    coderanch.com

Hi all, I have created a template jsp with header and footer.The body content will be a static content(html) that will be coming from web server.For that i have used c:import tag to retrieve from web server.Now the problem is we are having a old site eg.http://www.abc.com user will click a link in old site it is redirecting to our new ...

87. anything available just like static?    coderanch.com

88. static methods in Servlet    coderanch.com

89.  pages in static block of _jspService method    coderanch.com

Ill try again. (I'll be sure to avoid any catch phrases... :wink This message started the process: from log: 2010-03-19 11:19:29,265 org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:704) ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/application].[jsp]] Servlet.service() for servlet jsp threw exception org.apache.jasper.JasperException: Unable to compile class for JSP Generated servlet error: The code of method _jspService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) is exceeding the 65535 bytes limit at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84) at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328) at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:397) I changed a ...

92. Static on the JEE server    coderanch.com

Hallo, I have a running argument with colleague. His application has a front of EJBs. All those delegate the real work to classes which have only static methods. His reasoning is that this improves performance because no objects have to be instantiated. Of cause we know that this is not valid because the JEE server maintains a pool of EJBs which ...

93. static synchronized method in a StatelessSessionBean    coderanch.com

Hello, I have a question about thread synchronization in StatelessSessionBean in JEE 5 (JBoss 5.1): I have a stateless session bean with a method A that is called from a web application, triggered by a button click in a JSP. This method A checks the status of a specific entity bean B1. If it has the status "running" it throws an ...

99. static utility class from servlet    coderanch.com

Im pretty sure its ok but is it thread safe to use a static utility class from a servlet as long as you pass in the session or request object? I assume that if there is all member variables and no global ones everything is thread safe to process some code in a utility from a servlet like so? thanks public ...

100. Application Scope or Static Methods    coderanch.com