How do you use jsp code in xhtml page using facelets?
To use JSP code within an XHTML page using Facelets, you can employ the <jsp:include> tag to include a JSP file in your Facelets page. However, it's generally recommended to keep your code consistent by using either Facelets or JSP. If you decide to mix them, ensure that your server supports both and that you properly configure the web.xml for Facelet views. Lastly, remember that you should use Facelets features like managed beans and EL expressions for a more seamless integration.
Which is the website for jsp tutorials?
There are many websites for JSP Tutorials. Just google with text as "JSP Tutorials" or click on the related links in this answer...
What is the Expansion for JSP?
JSP stands for Java Server Pages. They are used in Java Enterprise applications that are created to be used on web pages. The JSP page acts as the user interface for the enterprise application.
What is the difference between asp and servlet?
ASP is a server side technology which enables a developer to combine both HTML & scripting language in the same page.
servlets are server side programs written in java.It is platform independent
What are the JSP lifecycle methods?
The 3 life cycle methods in a JSP page are:
A Servlet is a Java class that is the heart & brain of web applications.
Web applications are applications that are viewed via the browser.
Let me explain with an example.
You are now in wikianswers website. You have a bunch of links on the left side of this page. When you click on any of them you can see that the page goes somewhere and then reloads with fresh content.
Once you click the system goes to the servlet. Based on the link you clicked the servlet would decide which page to open and then it will fetch the necessary information that would be needed for the page.
Difference between JSP and CGI programming?
JSP stands for JAVA SERVER PAGES, where as CGI stands for COMMON GATEWAY INTERFACE.
In CGI, whenever a multiple requests of the same dynamic web page is made by the client to the server, a new process is cerated of the corrosponding CGI program, for each an every request generated as such..
this is not the case in JSP..
in JSP, when the first request is made for a dynamic web page..its corrosponding class file an hence the servlet is then cached in the memorey, and hence new threads are generated for the futher requests made, saving resources..
What are the Implicit object in JSP?
The implicit objects in a JSP page are:
A Servlet Mapping is a directive in the web.xml that tells the Servlet Container which class to use when a particular Servlet is called. A Servlet is a class within your Java Web Application. Let's say you have a servlet called MyServlet in the com.example.servlet package. You would need to have a Servlet Mapping pointing the path "/MyServlet" to the "com.example.servlet.MyServlet" class. Without the servlet mapping, you would not be able to invoke your servlet because the Servlet container would not know where it is. JSPs are different - they do not need mappings like this. JSPs exist within the WebRoot of the application, so they are always available. Servlets exist in the WEB-INF\Classes directory once your application is deployed.
Difference between temporary servlet and permanent servlet?
A temporary servlet is started when a request arrives and shut down after the response is generated. A permanent servlet is loaded when the server is started and lives until the server is shut down.
* This is useful when startup costs are high, such as a servlet that establishes a connection to a database.
* Also useful for permanent serverside service, such as an RMI server.
* Provides faster response to client requests when this is crucial. Being temporary or permanent is part of the server configuration.
What is tag lib directive in jsp?
The tag lib directive is used in JSPs to include tag libraries.
< % @ taglib uri=http://www.myCompany.com/myTagLibrary prefix="myLibrary" % >
This is how you include a tag library into a JSP
What is difference between single threaded servlet and multi threaded servlet?
The single thread model means that your servlet would not be multi-threaded. If there are two concurrent requests to your servlet then 2 instances of your servlet will be created to process these 2 requests. You can implement the single thread model by implementing the SingleThreadModel interface in your class. This is just a marker interface and does not have any methods. The multi threaded model means that your servlet would be multi-threaded and only one instance would exist. Multiple concurrent requests would be served by the same instance but in different threads. You can implement the multi threaded model by not implementing the SingleThreadModel interface in your servlet class.
How to Remove cache from browser using jsp?
By setting properties that prevent caching in your JSP Page. They are:
<% response.setHeader("pragma","no-cache");//HTTP 1.1
response.setHeader("Cache-Control","no-cache");
response.setHeader("Cache-Control","no-store");
response.addDateHeader("Expires", -1);
response.setDateHeader("max-age", 0);
//response.setIntHeader ("Expires", -1);
//prevents caching at the proxy server
response.addHeader("cache-Control", "private"); %>
What is difference between GET and POST in servlets in java?
The difference between a GET and a POST is the way data is transferred to a servlet. With a GET, the URL will show each name/value pair on the query string in the URL. For example, if you had a form with a field named 'foo,' and when submitted had a value of 'bar,' the URL might be something like this:
http://www.example.com/servlet?foo=bar
With a POST, this information is not visible in the URL. Instead, it is transferred in the HTTP headers. As far as the actual servlet is concerned, there is not a great deal of difference when it comes to getting the parameters. Whether you use a GET or a POST, you still use request.getParameter("foo"); to get the value.
The method used in the Servlet for processing either a GET or a POST is different too. If you use a GET, the method that is called is doGet(HttpServletRequest, HttpServletResponse). The doGet method is also called if there is no GET or POST data. If you use a POST, the method called is doPost(HttpServletRequest, HttpServletResponse).
What is the difference between pageContext and page implicit objects in JSP?
The page object represents the generated servlet instance itself, i.e., it is same as the "this" keyword for a Java file. As a result, you do not typically know who the super class is, and consequently do not normally make use of this object or its methods.
The pageContext object represents the environment for the page, containing useful information like page attributes, access to the request, response and session objects, as well as the JspWriter referenced by out. This object also has methods for including another URL's contents, and for forwarding or redirecting to another URL. For example, to forward a request to another resource from in a JSP page, we can do that by using the pageContext variable: pageContext.forward ("other.jsp");
Each web application contains a Session that can contain data that can be commonly made available to all the parts of the web application. The Session can be accessed from both the JSP and the Servlet.
Ex:
The servlet contains references to the HttpRequest object. So to access the session you can do so as below:
HttpSession session = request.getSession();
What is reason for separating business logic and presentation in JSP?
There can be a few different reasons for doing this.
One is to separate the actual work being done and who is doing it. Have a business logic developer working independently from a creative web developer.
Another reason would be for re-use. Developing reusable business logic components makes sense, instead of embedding that logic where it can't easily be reused in the front end.
What is the difference between JSP and Servlets?
A JSP is typically oriented more towards displaying information, and a servlet is more oriented towards processing information. For example, a JSP might display a report, while a servlet would process a user submitted form. These uses are not exclusive, but they are optimized more for performing tasks in this manner. It is much easier to incorporate HTML coding into a JSP than a Servlet. It is also easier to write more complex Java code in a servlet.
AnswerJSP has Implicit objects and Servlets do not. AnswerJSP and Servlet both define the server end functionality to provide dynamic outputs ,As we know our HTML is only the client end technology version which runs on client browser. JSP and Servlet differ each other in terms of represntation and execution cycle. Servlet are full functional java codes that define the output like write to stream files in protocol defined ways, JSP on the other hand is Role Sepated format to do so where a ordinary web designer designes how will be the presentation of the data and Programmer defines the functinality to provide the underlying things represented in conditional and non conditinal ways , But here is the magic of JSp that merges the both HTML represntation mixed with JAVA scriptlets.Look at http://www.jsptube.com/jsp-tutorials/jsp-introduction.html, it explains how does JSP differs from servlet.
What are the built in objects in jsp?
The correct term is "JSP Implicit Objects"
In any JSP Page, there are a bunch of implicit objects that are available for the programmer to use. It contains a variety of information that can be used to display stuff on the page. The following JSP Implicit Objects that are available for a programmer.
• request
• response
• out
• session
• config
• application
• page
• pageContext
There are several types of context clues that can help readers understand the meaning of unfamiliar words, including definition or explanation clues (when the meaning of the word is directly stated), synonym or restatement clues (when a similar word or phrase is used), contrast or antonym clues (when the opposite meaning is given), and example or illustration clues (when specific examples are provided).
What is the difference between HTML and JSP?
HTML is client side. JSP is server side.
HTML provides a means to describe the structure of text-based information in a document - by denoting certain text as links, headings, paragraphs, lists, and so on - and to supplement that text with interactive forms, embedded images, and other objects. HTML is written in the form of tags, surrounded by angle brackets. HTML can also describe, to some degree, the appearance and semantics of a document, and can include embedded scripting language code (such as JavaScript) which can affect the behavior of Web browsers and other HTML processors.
The JSP syntax adds additional XML-like tags, called JSP actions, to be used to invoke built-in functionality. Additionally, the technology allows for the creation of JSP tag libraries that act as extensions to the standard HTML or XML tags. Tag libraries provide a platform independent way of extending the capabilities of a Web server. JSP is alot like php.
How do you refresh a jsp page automatically?
by using the meta tag <meta HTTP-EQUIV="Refresh" CONTENT="5(duration in sec)">
The javax.servlet.Servlet interface defines the three methods known as life-cycle method.
public void init(ServletConfig config) throws ServletException
public void service( ServletRequest req, ServletResponse res) throws ServletException, IOException
public void destroy()
First the servlet is constructed, then initialized wih the init() method.
Any request from client are handled initially by the service() method before delegating to the doXxx() methods in the case of HttpServlet.
There are two more methods.....
public abstract String getServletInfo()
public abstract ServletConfig getServletConfig()