CS506 Current FinalTerm Paper 24 August 2016



CS506 Current FinalTerm Paper 24 August 2016


1. Suppose we have two threads t1 with high priority and t2 with low priority. Thread t1 is creating starvation due to high priority. How this starvation condition can remove and let thread t2 to get process. Give code example
Note: Thread 2 will not stop working and you are not allowed to change the priority of thread t2. 

2. Why Swing model cannot be used in web applications?

3. Suppose you are developing a web application in java servlet and application required some initialization parameters before starting the application. Write the name of file where you will write initial values. 


4. Suppose you want to use FileReader and ResultSet classes in JSP page. How you
will import both classes into JSP page?


5. A problem arises if a process A that needs 20 iterations to execute has highest priority while process B needs 5 iterations but has lowest priority. In this situation process B may has to wait if process A has to call again and again. If you face such a situation how will you resolve this?


6. Give one advantage and two disadvantages of Page centric approach?

7. What will be the output of following program?
MyServlet process request method:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<h1>Start of include request </h1>");
out.flush();
ServletContext context = getServletContext();
RequestDispatcher rd = context.getRequestDispatcher("/includeservlet");
rd.include(request, response);
out.println("<h1>End of include request</h1>");
out.println("<h1> Requests finished</h1>");
out.println("</body>");
out.println("</html>");
out.close();
}
IncludeServlet processRequest() method:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<h1> <marquee>I am included </marquee></h1>");
out.close();
}


8. Write the following statements using JSP expression that
1. Display current Date & Time
2. Get and display ‘id” sent by the user through some html form.

9. Suppose we want to make the following Student class {} serializeable but we do not want to serialize the name, subject and grades of the student. Rewrite the following class to implement the required changes as well as make this class run able:
class Students {
String name;
String id;
String subject;
String grades;
public Student(String n, String id, String s, String g)
{
name = n;
id = id;
subject = s;
grades=g;
}
public void printRecord ( ) {
JOptionPane.showMessageDialog(null , “name: ” name “id” +id +”subject”+subject+”grades”+grade);
}
} // end class


10. Write a method processRequest() of the servlet that takes name of university “uni” from “uni.html”. If user enters”vu” it displays "VUHome.html" page while if user enters “nust” it displays "NUSTHome.html" page. In case of any other field entered by user it displays error "No data/content related to the site found". Use the following code structure.


11. Write a code for an error page that displays the following output. The same error page is displayed for null pointer exception or any unknown exception if it occurs.Use html and jsp tags.
Required output:
You are on error page
An …… Exception has occurred.
Please ask the network administrator
The Error Message was “type of error….”
Please Try Again Later!
Note:
• In dotted lines specify the type of exception that occurred like “An SQL Exception has occurred”.
• In “type of error….” Specify the error message you got while exception handling.


12. Write a JSP page that gets the value of “amount” from an html page, calculate Zakat on it and display the calculated Zakat.
Note: Use the following overall format of the program.
<html>
<body>
<!-- JSP to calculate Zakat-->
<%-- Declaration --%>
<%!
//your code here
%>
<%-- Scriptlet --%>
<%
//your code here
%>
<%-- expression used to display Zakat --%>
<h3>Zakat value is:
<%
// your code here
%>
</h3>
</body>
</html>

Welcome to Our WebSite! - | LMS Help | Pakistan NO # 1 . Website for the Students of Virtual University.

Next
Previous
Click here for Comments

0 comments: