JSP / Servlets

¡Supera tus tareas y exámenes ahora con Quizwiz!

What is a stored procedure, and how do you create one?

"A procedure stored on a database that is used by callable statements in the Java App. to make one, use CREATE or REPLACE procedure emp(id in NUMBER, name in VARCHAR2) "

What happens if too many people use a resource, (i.e. you create more connections than the connection pool)?

Another Connection Object is made and, once finished, placed in the pool

How do you do IF ELSE on a JSP page?

The if...else block starts out like an ordinary Scriptlet, but the Scriptlet is closed at each line with HTML text included between Scriptlet tags. Also if it was a simple if else statment i would use jstl and the Terenary Operator.

How would you preinitialize/preload a servlet?

Use the <load-on-startup>(priority integer greater than zero)</load-on-startup> tag in the Web.xml section describing the servlet in question. When the server starts, it will instantiate and initialize the servlets in priority order.

In which directory is web.xml located?

WEB-INF

What is connection pooling?

When a database server uses a collection of Connection objects for each user. The Connection objects aren't removed whent they are finished, merely placed into the pool for it to be used again later

What is the difference between a doGet and doPost methods in Servlet?

a doGet will cause the data to append to the url, while a doPost will not. Both methods can be overriden to do seperate things; however, typically they perform the same function.

What are the lifecycle methods of a Servlet?

init(), service(), destroy()

How do you use weblogic to talk to a database?

server managed and datasource

What is a ServletContext?

they are context parameters for all the servlets.

Can I do whatever I want to do in JSP instead of a Servlet?

"JSP should only be used to output information. while you can do business logic in a jsp, it is recommended to do it in a servlet or POJO then redirect to a jsp. But, yes, you CAN run pretty much any Java code in a servlet."

What do you know about Session ID?

A SessionID is a piece of data used to identify distinct sessions (stored data that is unique for each individual user)

What is the difference between PL/SQL and SQL 2.0?

...

Name some important tags in ServletConfig.

<init-name> <init-value>

Can you name some standard action tags in JSP?

<jsp:include> <jsp:setProperty> <jsp:getProperty>

Name some important tags in ServletContext.

<param-name> <param-value>

What's the difference between a Servlet and a JSP?

A JSP is a DHTML page with Java code embedded directly into it. A servlet is a Java class that is called by a web page. A Servlet also requires mapping in the web.xml file, whereas a JSP does not.

What is a directive and can you name some directives in JSP?

A directive is a type of scriptlet that imports into a jsp.

What are the different ways of handling a session?

Cookies (text files stored on the client side), URL Rewriting, or Session Objects (stored on the server side)

How would you write a message back to the browser from inside a Servlet?

Create a PrintWriter object, then use a print method, such as println()

What methods do we need to override in Servlet?

DoGet and DoPost

What are foreign keys?

Foreign keys are used to allow one table to correlate its own data with the contents of some other table.

What is the difference between http GET and POST methods?

GET appends data to the url and has a limit of 3000, POST does not append data and is unlimited

What is the difference between Generic Servlet and HTTP Servlet?

Generic Servlet is not tied to any protocol. HTTP Servlet is tied to Hypertext Transfer Protocol

What are the classes we need to implement in Servlet?

HTTPServlet

Why should Prepared Statements be used?

If you will be running a similar statement repeatedly, for example parsing a data file and filling in a table, a prepared statement is convenient to write. In addition, since the SQL is compiled before making the request to a server, it reduces server load and can improve program performance.

What are the steps for reading a table using JDBC?

Initialize the proper driver, depending on what kind of database you need to access. Then, provide the datastream (URL, username, password). Read the data in question by using a ResultSet object and the executeQuery Statement method. Close the connection when you're finished.

What are the different joins in Oracle?

Inner, Right Outer, Left Outer, Full Outer, Cross

What is JSTL?

JSP Tag Library

Can you name some JDBC drivers?

MySQL driver, Oracle driver, SQLServer driver

Which method (http GET or http POST) would you use if you had a very long message to transfer?

POST since GET has a character limit

How do you prevent SQL injection?

Parameterize your queries. Preventing SQL injection is one of the major reasons for Callable statements.

What is the difference between RequestDispatcher.forward() and Response.SendRedirect()?

Request dispatcher does not change the URL for the user, the redirect will change the URL

If you have a table with employee names and department id and another with department id and department name, give a SQL statement to get all employees in the "ACCOUNTING" department.

SELECT * FROM employee JOIN department ON employee.departmentID = department.departmentID WHERE departmentName='ACCOUNTING'.

What are the various types of mark-up tags provided by JSP?

Scriptlets, Declaratives, Directives, Expressions, Comments

What are the scopes of a JSP?

Session, Page, Request, Application

What is the lifecycle of a JSP?

Translation->Compilation->Loading->Instantiation->JSP_init()->JSP_service()->JSP_destroy()

What is the difference between XML and HTML?

XML is for describing and storing data and is case-sensitive, while HTML is only for displaying data and is not case-sensitive

What are XML parsers and how have you used them?

XML parsers go through XML data and allow us to present it in a more human readable format. I have used them, especially in the context of Web Services.

What is the difference between a static and dynamic include in JSP?

a static include gets included at the translation stage of the jsp, forming one servlet. While a dynamic include gets included during runtime.

What is an outer join?

a union between two tables. An inner join, in contract, is the intersection between two tables

How does the application know how many users are using a resource?

by how many connections are being used from the pool

How do you optimize queries?

by using prepared statements

Why do we have both doGet and doPost methods in Servlet instead of just one?

in case the html editor uses one or the other, the servlet is prepared to handle both

How would you access a Servlet that you create?

in the front end JSP or HTML, in the form action, you would write a .do statement. This would then be mapped in the XML file which would lead it to the servlet

How many times are the Servlet lifecycle methods called when a web application runs?

init() and destroy() are called once. service() is called for every request

What is a trigger?

it is an automatic response to a specific event

What is a ServletConfig?

it is the initialization parameters for one servlet

How do you validate an xml file?

make sure it follows all the rules of a DTD/schema

How would you forward a request from a Servlet to a JSP?

request.getRequestDispatcher("/name.jsp").forward(request, response);

What is the process of a simple login function, from the front end all the way to the database?

user inputs information into login HTML, a servlet authenticates the information given by using a POJO which obtains values from a database. The POJO will return true or false if the information matches the database and the servlet will redirect the user based on that answer.


Conjuntos de estudio relacionados

Quiz-Quiz Swap: Pertanyaan Ujian Lisan

View Set

P&C Chapter 5 - Missouri Statutes, Rules and Regulations Common to All Lines

View Set

Sustainable Development Goals (SDGs)

View Set

Gram positive and Gram negative bacteria

View Set

Unit 2 python example quiz that helps he get a 100

View Set

Micro Final (Exercises, Tests and Quizzes)

View Set

2nd half: section 9 Loan Qualification & Financing in. WA

View Set