answersLogoWhite

0

JSP and Servlets

JSP (JavaServer Pages) are Java programs encoded within webpages that research and generate pertinent results. Servlets, on the other hand, are objects (programs) that handle requests from users and provide results based on these requests.

261 Questions

How do you learn Java Programming?

you go to school to learn it or you can read books on your own particuarly at amazon just search java programing or google it

One of the best ways to learn a new programming language is to write programs in it. Try rooting around in the Java Programming category on this site. Look for questions like "Write a program to...?" and see if you can figure out how to answer them.

Sun (now Oracle) has a whole website dedicated to the online versions of print books about learning the various parts and techniques of Java, including a very good introduction to Java programming language.

What is a request object in asp technology?

The ASP Request object is used to get information from the user. From http://www.w3schools.com/ASP/asp_ref_request.asp

Why httpservlet class called abstract?

Because, the creators of the servlet framework cannot give all the functionality that you might want in your application.

So, if they make their class abstract, you the developer will be providing all the functionality you need and still stick to the framework standards defined by them.

What is the syntax to call a jsp page from HTML button?

There are several ways to use an HTML button to go to a web page. You can keep it simple. This example uses "page.jsp" in the same directory as your HTML page for your target location. You can use the following code:


How can you insert a picture into a jsp?

You can do that using the <img> tag.

<img src="URL" />

Here URL refers to the path where the actual jpg image is saved in the application path.

What is HttpServletRequest?

ServletRequest provides the functionalities to the classes to access the HTTP requests. The servlet container creates an HttpServletRequest object and an HttpServletResponse object, and passes them as arguments to the servlet's service methods such as doGet, doPost, etc.

What is servlet cookies in java programming?

a small amount of information sent by a servlet to a Web browser, saved by the browser, and later sent back to the server. A cookie's value can uniquely identify a client, so cookies are commonly used for session management.

A cookie has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum age, and a version number. Some Web browsers have bugs in how they handle the optional attributes, so use them sparingly to improve the interoperability of your servlets.

The servlet sends cookies to the browser by using the HttpServletResponse.addCookie(javax.servlet.http.Cookie) method, which adds fields to HTTP response headers to send cookies to the browser, one at a time. The browser is expected to support 20 cookies for each Web server, 300 cookies total, and may limit cookie size to 4 KB each.

The browser returns cookies to the servlet by adding fields to HTTP request headers. Cookies can be retrieved from a request by using the HttpServletRequest.getCookies() method. Several cookies might have the same name but different path attributes.

Cookies affect the caching of the Web pages that use them. HTTP 1.0 does not cache pages that use cookies created with this class. This class does not support the cache control defined with HTTP 1.1.

What function of java server pages?

Java Server Pages have become an integral part of any J2EE application. They are used extensively because they can combine the features of HTML and Java. The difficulty level of JSP is half-way between HTML and pure Java. For simple tasks like displaying the current date, you write a normal HTML page and add only a small amount of Java as a scriptlet. For big tasks like processing a shopping cart, you use JSP as the mediator between the Web form and a component (Ex: Servlet) that has all the processing logic.

CGI, Perl, Active Server Pages etc were all the predecessors of Java Server Pages. Am not saying that the JSP Technology was built based on these technologies but it is safe to say that, the JSP Technology was created to overcome many of the shortcomings in the above mentioned technologies. Though the ASP technology is a web server scripting champion and is used very widely, the only problem is the Runs only in Windows Attitude of the technology. Unlike ASP, JSP has equivalent if not better features and can run in any environment making it an invaluable tool for enterprise application developers who don't want to be tied to the limitation of the system running only in Windows.

Not only does JSP run on all major platforms, but the JavaBeans used by these JSPs run on all major platforms as well.

JSP competes directly with ASP. In fact, you would be forgiven if you thought it was a copy. Sun took the same approach to JSP as it did with Java. Sun borrowed the syntax of its best competitor (ASP for JSP and C++ for Java) tweaked it a little, but built everything under the hood from scratch. Java syntax comes from C++, but it works on all platforms with no portability issues like C++ for the developer. Similarly, the JSP structure comes from ASP. The look and feel, and even some syntax is the same. However, ASP primarily uses Microsoft's versatile VBScript, while JSP uses the more powerful and portable Java and JavaScript.

How to upload excel sheet data into a MySQL database using JSP and Servlets?

It is very easy to upload excel spreadsheet data into a MySQL database using JSP and servlets. Within Java there is a tool where you can designate the name and location of the file you would like to import. Once you furnish the file name Java server pages will do the work for you.

How do you make a scientific calculator program in java?

import java.io.*;

import java.util.*;

public class Calculator

{

public static void main(String args[])

{

System.out.println("Make your arithmetic selection from the choices below:\n");

System.out.println(" 1. Addition");

System.out.println(" 2. Subtraction");

System.out.println(" 3. Multiplication");

System.out.println(" 4. Division\n");

System.out.print(" Your choice? ");

Scanner kbReader = new Scanner(System.in);

int choice = kbReader.nextInt();

if((choice<=4) && (choice>0))

{

System.out.print("\nEnter first operand. ");

double op1 = kbReader.nextDouble();

System.out.print("\nEnter second operand.");

double op2 = kbReader.nextDouble();

System.out.println("");

switch (choice)

{

case 1: //addition

System.out.println(op1 + " plus " + op2 + " = " + (op1 + op2) );

break;

case 2: //subtraction

System.out.println(op1 + " minus " + op2 + " = " + (op1 - op2) );

break;

case 3: //multiplication

System.out.println(op1 + " times " + op2 + " = " + (op1 * op2) );

break;

case 4: //division

System.out.println(op1 + " divided by " + op2 + " = " + (op1 / op2) );

}

}

else

{

System.out.println("Please enter a 1, 2, 3, or 4.");

}

}

}

Read more: How_do_you_make_calculator_program_in_java

How do you convert HTML to JSP?

You cannot. A JSP Page contains a lot more contents than just HTML. It contains JavaScript, Java Scriptlets etc. So a HTML cannot be directly converted to a JSP unless someone sits and adds the other contents to the JSP that makes it a JSP

What is JSP?

In the context of Computer Programming, JSP stands for Java Server Page. A JSP is basically an HTML file with Java code inserted to make a dynamic page.

AnswerJacketed soft point in the context of bullets. AnswerJSP, Java Server Pages, is a language for mixing HTML/XML and Java in the same page.

Basic JSP can look like this:

...

Welcome, <%=user.getName()%>

...

where <%=...%> tells the server to execute the contents of the tag as Java and print the result to the page.

See related link.

Which application server support java platform?

All major servers like Weblogic, Webspher, Tomcat support Java Platform

How are JSPs better than Servlets?

Though Servlets were awesome when compared to CGI, they still had some issues when it came to displaying dynamic content on a web page. Thankfully, Sun released the JSP (Java Server Pages) specifications in 1998, which solved all our UI woes. JSPs enabled programmers to display dynamic HTML content that could also use Java features.

Why need webxml file for servlet?

Deployment Descriptor is probably the most important part of any web application. Even if you have all your servlets, JSPs, Jars etc set up properly, the system wouldn't run fine unless you set up the deployment descriptor properly

What are the applications of JSP web language?

JSP stands for Java Server Pages. It is a technology based on Java and similar to Servlets. It acts as the front end or user interface layer of Web applications. It takes advantage of HTML and Java Script and can contain code that involves both these technologies.

Is tubemate safe?

Yes 100% if downloaded from a verified site. There are so many infected versions out there, on Google Play and the net in general. Be careful use a verified site you trust, and a good security program to protect you.

What is olap?

OLAP stands for Online Analytical Processing. An OLAP system can be considered as a category of applications and technologies that are used for collecting, managing, processing and presenting multi-dimensional data for analysis and management purposes.

How do you display the host name and ip address using Servlets?

The host name and the ip address is present in the HttpRequest object. Usually it is passed as an argument to the doXXX methods.

public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {

// Get client's IP address

String ipAddress = req.getRemoteAddr();

// Get client's hostname

String hostname = req.getRemoteHost();

}

What is the difference between variable declared inside the declaration part and variable declared in scriptlet part?

Variable declared inside declaration part is treated as a global variable, which means after translation of jsp file into servlet

  • that variable will be declared outside the service method as an instance variable
  • the scope is available to the complete jsp

Variable declared inside a scriplet will be declared inside a service method as a local variable and the scope is with in the service method.

Is java server pages a front end or back end?

Java Server Pages Technology is used to create efficient and powerful front end's for Web Applications.