JSP homework Help at TutorEye

Top Questions

5.In this problem and the next one, we’re going to make a very simple spam checker program by just looking ...

ooking at how likely a given email is to be spam based on the words it contains. In particular, in this problem we’re going to count how often words are present in spam emails within some set of training data (which here means a set of emails that have already been marked as spam or not spam manually). We have already started to write a function spam_score(spam_file, not_file, word), which takes in two filenames, along with a target word (a lowercase string). Both filenames refer to text files which must be in the same directory as hw07.py (we’ve provided several such files in hw07files.zip). The text files contain one email per line (really just the subject line to keep things simple) - you can assume that these emails will be a series of words separated by spaces with no punctuation. The first file contains emails that have been identified as spam, the second contains emails that have been identified as not spam. Since you haven’t learned File I/O yet, we’ve provided code that opens the two files and puts the data into two lists of strings (where each element is one line - that is, one email). You then must complete the function, so that it returns the spam score for the target word. The spam score is an integer representing the total number of times the target word occurs across all the spam emails, minus the total number of times the word occurs in not-spam emails. Convert all words to lowercase before counting, to ensure capitalization does not throw off the count.
View More

JSP: 

 

JSP stands for Jakarta Server Pages and it is a collection of technologies that facilitates the developers in creating dynamically generated web pages that are based on HTML, XML, SOAP, etc. It is quite similar to Serverlet Technology and is sometimes thought of as its extension because it provides more functionality. 

 

JSP Sample Questions:

 

 

Question 1: Which of the following attribute of the page directive should be used to generate a pdf page?

 

A) typePDF

B) contentType

C) contentPDF

D) None of these

 

Answer: contentType

Explanation: Following is the correct way to generate a pdf by using contentType attribute of page directive:
<%page contentType="application/pdf">

 

Get the full solution!

 

 

Question 2: Mandatory attributes in <jsp:setProperty /> tag are?

 

A) type, id

B) name, property

C) name, id

D) None of these


Answer: name, property

Explanation: Property of bean is set by setProperty action. Before the action, the bean must be previously defined.

 

Get the full solution!

 

 

Question 3: Which of the following is the correct way to pass the information from JSP to included JSP?

 

A) <%jsp:param>

B) <%jsp:import>

C) <%jsp:page>

D) None of these


Answer: <%jsp:param>

Explanation: The correct way to pass the information from JSP to included JSP is by using the <%jsp:param> tag.

 

Get the full solution!


 

Question 4: Which of the following is the valid difference between Servlets and JSP? 

 

A) Compilation

B) Syntax

C) Translation

D) Both B and C


Answer: Syntax 

Explanation: JSP is quite similar to Serverlet Technology and is sometimes thought of as its extension because it provides more functionality. Compilation and Translation are the same whereas they are different in syntax.

 

Get the full solution!


 

Question 5: Which of the following in JSP is not a directive?

 

A) page 

B) userBean

C) include

D) export

 

Answer: export

Explanation: page, userBean and include are valid JSP directives whereas export is not a valid JSP directive.

 

Get the full solution!


 

Question 6: Which of the following interfaces does the javax.servlet.jsp package contains?

 

A) HttpJspPage

B) JspWriter

C) PageContext

D) All of these 


Answer: HttpJspPage

Explanation: The javax.servlet.jsp package contains the following interfaces:
HttpJspPage
JspPage

 

Get the full solution!


 

Question 7: Which of the following is not a valid class that javax.servlet.jsp package contains?

 

A) JspFactory

B) JspWriter

C) ErrorData

D) None of these

 

Answer: None of these

Explanation: The javax.servlet.jsp package contains the following classes:
JspFactory
JspWriter
ErrorData
JspContext
JspEngineInfo
PageContext

 

Get the full solution!


 

Question 8: Which of the following is the correct number of jsp implicit objects?

 

A) 7

B) 8

C) 9

D) 10

 

Answer: 9

Explanation: Following are the jsp implicit objects:
request
out
response
application
config
session
page
pageContext
exception

 

 

Get the full solution!

 


Question 9: Which of the following tag can be used for executing the java source code in JSP?

 

A) Expression tag

B) Scriptlet tag

C) Declaration Tag

D) None of these


Answer: Scriptlet tag

Explanation: Following are the uses of the above following tags:
Expression tag: writing user’s content on the client-side.
Scriptlet tag: executing the java source code.
Declaration Tag: declare fields and methods

 

Get the full solution!


 

Question 10: How many ways are there to handle exceptions in JSP?

 

A) 1

B) 2

C) 4

D) None of these

 

Answer: 2

Explanation: There are following two ways to handle exceptions in JSP:
errorPage: it is used to site which page to be shown when the exception has occurred.
isErrorPage: it is used to mark the pages as an error page where the exceptions are displayed. 

 

Get the full solution!

 

 

 

Computer Science Question Answers Pages


 

Programming in C and C Plus Plus Programming in Java Internet Programming
Screen Readers Android Programming Programming in Python C Sharp Programming