Sie sind auf Seite 1von 7

General FAQ What is JavaServer Pages technology?

JavaServer Pages (JSP) technology provides a simplified, fast way to create web pages that display dynamically-generated content. The JSP specification, developed through an industry-wide initiative led by Sun Microsystems, defines the interaction between the server and the JSP page, and describes the format and syntax of the page. How does the JavaServer Pages technology work? JSP pages use XML tags and scriptlets written in the Java programming language to encapsulate the logic that generates the content for the page. It passes any formatting (HTML or XML) tags directly back to the response page. In this way, JSP pages separate the page logic from its design and display. JSP technology is part of the Java technology family. JSP pages are compiled into servlets and may call JavaBeans components (beans) or Enterprise JavaBeans components (enterprise beans) to perform processing on the server. As such, JSP technology is a key component in a highly scalable architecture for web-based applications. JSP pages are not restricted to any specific platform or web server. The JSP specification represents a broad spectrum of industry input. What is a servlet? A servlet is a program written in the Java programming language that runs on the server, as opposed to the browser (applets). Detailed information can be found at http://java.sun.com/products/servlet. Why do I need JSP technology if I already have servlets? JSP pages are compiled into servlets, so theoretically you could write servlets to support your web-based applications. However, JSP technology was designed to simplify the process of creating pages by separating web presentation from web content. In many applications, the response sent to the client is a combination of template data and dynamically-generated data. In this situation, it is much easier to work with JSP pages than to do everything with servlets. Where can I get the most current version of the JSP specification? The JavaServer Pages 2.0 specification is available for download from here. How does the JSP specification relate to the Java 2 Platform, Enterprise Edition?

The JSP 2.0 specification is an important part of the Java 2 Platform, Enterprise Edition 1.4. Using JSP and Enterprise JavaBeans technologies together is a great way to implement distributed enterprise applications with web-based front ends. Which web servers support JSP technology? There are a number of JSP technology implementations for different web servers. The latest information on officially-announced support can be found at http://java.sun.com/products/jsp/industry.html. Is Sun providing a reference implementation for the JSP specification? The J2EE SDK is a reference implementation of the JavaTM 2 Platform, Enterprise Edition. Sun adapts and integrates the Tomcat JSP and Java Servlet implementation into the J2EE SDK. The J2EE SDK can be used as a development enviroment for applications prior to their deployment and distribution. Tomcat a free, open-source implementation of Java Servlet and JavaServer Pages technologies developed under the Jakarta project at the Apache Software Foundation, can be downloaded from http://jakarta.apache.org. Tomcat is available for commercial use under the ASF license from the Apache web site in both binary and source versions. An implementation of JSP technology is part of the J2EE SDK. How is JSP technology different from other products? JSP technology is the result of industry collaboration and is designed to be an open, industry-standard method supporting numerous servers, browsers and tools. JSP technology speeds development with reusable components and tags, instead of relying heavily on scripting within the page itself. All JSP implementations support a Java programming language-based scripting language, which provides inherent scalability and support for complex operations. Where do I get more information on JSP technology? The first place to check for information on JSP technology is http://java.sun.com/products/jsp/. This site includes numerous resources, as well as pointers to mailing lists and discussion groups for JSP technologyrelated topics. Technical FAQ What is a JSP page?

A JSP page is a page created by the web developer that includes JSP technology-specific and custom tags, in combination with other static (HTML or XML) tags. A JSP page has the extension .jsp or .jspx; this signals to the web server that the JSP engine will process elements on this page. Using the web.xml deployment descriptor, additional extensions can be associated with the JSP engine. The exact format of a JSP page is described in the JSP specification.. How do JSP pages work? A JSP engine interprets tags, and generates the content required - for example, by calling a bean, accessing a database with the JDBC API or including a file. It then sends the results back in the form of an HTML (or XML) page to the browser. The logic that generates the content is encapsulated in tags and beans processed on the server. Does JSP technology require the use of other Java platform APIs? JSP pages are typically compiled into Java platform servlet classes. As a result, JSP pages require a Java virtual machine that supports the Java platform servlet specification. How is a JSP page invoked and compiled? Pages built using JSP technology are typically implemented using a translation phase that is performed once, the first time the page is called. The page is compiled into a Java Servlet class and remains in server memory, so subsequent calls to the page have very fast response times. What is the syntax for JavaServer Pages technology? The syntax card and reference can be viewed or downloaded from our website. Can I create XML pages using JSP technology? Yes, the JSP specification does support creation of XML documents. For simple XML generation, the XML tags may be included as static template portions of the JSP page. Dynamic generation of XML tags occurs through bean components or custom tags that generate XML output. See the white paper Developing XML Solutions with JavaServer Pages Technology (PDF) for details. Can I generate and manipulate JSP pages using XML tools? The JSP 2.0 specification describes a mapping between JSP pages and XML documents. The mapping enables the creation and manipulation of JSP pages using XML tools. How do I use JavaBeans components (beans) from a JSP page?

The JSP specification includes standard tags for bean use and manipulation. The useBean tag creates an instance of a specific JavaBeans class. If the instance already exists, it is retrieved. Otherwise, it is created. The setProperty and getProperty tags let you manipulate properties of the given object. These tags are described in more detail in the JSP specification and tutorial.

What is the query used to display all tables names in SQL Server (Query analyzer)? 2. select * from information_schema.tables 3. How many types of JDBC Drivers are present and what are they?- There are 4 types of JDBC Drivers o JDBC-ODBC Bridge Driver o Native API Partly Java Driver o Network protocol Driver o JDBC Net pure Java Driver 4. Can we implement an interface in a JSP?- No 5. What is the difference between ServletContext and PageContext?ServletContext: Gives the information about the container. PageContext: Gives the information about the Request 6. What is the difference in using request.getRequestDispatcher() and context.getRequestDispatcher()?- request.getRequestDispatcher(path): In order to create it we need to give the relative path of the resource, context.getRequestDispatcher(path): In order to create it we need to give the absolute path of the resource. 7. How to pass information from JSP to included JSP?- Using <%jsp:param> tag. 8. What is the difference between directive include and jsp include?- <%@ include>: Used to include static resources during translation time. JSP include: Used to include dynamic content or static content during runtime. 9. What is the difference between RequestDispatcher and sendRedirect?RequestDispatcher: server-side redirect with request and response objects. sendRedirect : Client-side redirect with new request and response objects. 10. How does JSP handle runtime exceptions?- Using errorPage attribute of page directive and also we need to specify isErrorPage=true if the current page is intended to URL redirecting of a JSP. 11. How do you delete a Cookie within a JSP? 12. Cookie mycook = new Cookie(\"name\",\"value\"); 13. response.addCookie(mycook); 14. Cookie killmycook = new Cookie(\"mycook\",\"value\"); 15. killmycook.setMaxAge(0); 16. killmycook.setPath(\"/\"); 17. killmycook.addCookie(killmycook); 18. How do I mix JSP and SSI #include?- If youre just including raw HTML, use the #include directive as usual inside your .jsp file. 19. <!--#include file="data.inc"-->
1.

But its a little trickier if you want the server to evaluate any JSP code thats inside the included file. If your data.inc file contains jsp code you will have to use <%@ vinclude="data.inc" %> The <!#include file="data.inc"> is used for including non-JSP files. I made my class Cloneable but I still get Cant access protected method clone. Why?- Some of the Java books imply that all you have to do in order to have your class support clone() is implement the Cloneable interface. Not so. Perhaps that was the intent at some point, but thats not the way it works currently. As it stands, you have to implement your own public clone() method, even if it doesnt do anything special and just calls super.clone(). 21. Why is XML such an important development?- It removes two constraints which were holding back Web developments: dependence on a single, inflexible document type (HTML) which was being much abused for tasks it was never designed for; the complexity of full SGML, whose syntax allows many powerful but hard-to-program options. XML allows the flexible development of user-defined document types. It provides a robust, nonproprietary, persistent, and verifiable file format for the storage and transmission of text and data both on and off the Web; and it removes the more complex options of SGML, making it easier to program for. 22. What is the fastest type of JDBC driver?- JDBC driver performance will depend on a number of issues: o the quality of the driver code, o the size of the driver code, o the database server and its load, o network topology, o the number of times your request is translated to a different API.
20.

In general, all things being equal, you can assume that the more your request and response change hands, the slower it will be. This means that Type 1 and Type 3 drivers will be slower than Type 2 drivers (the database calls are make at least three translations versus two), and Type 4 drivers are the fastest (only one translation). How do I find whether a parameter exists in the request object? 24. boolean hasFoo = ! (request.getParameter(\"foo\") == null 25. || request.getParameter(\"foo\").equals(\"\"));
23.

or

boolean hasParameter = request.getParameterMap().contains(theParameter); // (which works in Servlet 2.3+)


26.

How can I send user authentication information while makingURLConnection?- Youll want to use HttpURLConnection.setRequestProperty and set all the appropriate headers to HTTP authorization.

Das könnte Ihnen auch gefallen