I need some details about an employee. i have only the
employee id in my presentation layer(JSP).I entered that ID
and click "Show Details" Button. Question is how the JSP
pass that id to Controller layer and DAO and what mechanism
we are using to retrive data from DB and how the data
passed to JSP as a Output. Please explain in detail.

Answer Posted / yagnik

Your jsp form action id when u press submit it will call
the action which is in html form action(some jsp,or
servlet) that jsp will able to get employee id throuh
req.getparameter('employee_id'); and then tht JSP use bean
class for connection to DB using JDBC and then it will
return result to the calling jsp and tht jsp will print
responce (employee details) and tht generated out put will
be sent to the client.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are triggers in DB? Explain their types. How do they work?

619


What is the purpose of tostring() method in java?

547


What are keywords in java?

572


Is static a keyword in java?

519


What is the new line character?

552






Is it possible to specify multiple jndi names when deploying an ejb?

553


What does replaceall do in java?

484


Is string is a data type in java?

587


What are the important features of Java 10 release?

508


Can a static member function access member variable of an object?

554


What is int lol?

590


What is unmodifiable collection in java?

505


What type of value does sizeof return?

532


The following program reads data (details of students) from a file named students.txt and converts it into e-mail addresses. The results are written to a file named studentemail.txt. students.txt consists of a number of lines, each containing the data of a student in colon delimited format: Last Name:First Name:Student Number Each input record is converted to an e-mail address and written to studentemail.txt in the following format: the first character of the last name + the first character of the first name + the last four digits of the student number + “@myunisa.ac.za” import java.io.*; public class EmailConverter { public static void main(String[] args) throws IOException { BufferedReader input = new BufferedReader(new FileReader ("students.txt")); PrintWriter output = new PrintWriter(new FileWriter ("studentemail.txt")); String line = input.readLine(); while (line != null) { // Extract the information for each student String[] items = line.split(":"); // Generate the email address String email = "" + items[0].charAt(0) + items[1].charAt(0) + items[2].substring(4,8) + "@myunisa.ac.za"; email = email.toLowerCase(); // Output output.println(email); line = input.readLine(); } input.close(); output.close(); } } Rewrite the class so that it handles possible errors that may occur. In particular, it should do the following: • It should catch at least three appropriate exceptions that might occur, and display suitable messages. • At this stage, the program will not run correctly if there is an empty line in the input file. Change the program so that if an empty line is encountered, an exception is thrown and the empty line is ignored. This exception should be handled with the display of a suitable error message. • Before the e-mail address is added to the output file, check if the student number has 8 digits. If not, throw an InvalidFormatException (which the program should not handle itself)

1449


3.2 Consider the following class: public class Point { protected int x, y; public Point(int xx, int yy) { x = xx; y = yy; } public Point() { this(0, 0); } public int getx() { return x; } public int gety() { return y; } public String toString() { return "("+x+", "+y+")"; } } Say you wanted to define a rectangle class that stored its top left corner and its height and width as fields. 3.2.1 Why would it be wrong to make Rectangle inherit from Point (where in fact it would inherit the x and y coordinates for its top left corner and you could just add the height and width as additional fields)? (1) 8 Now consider the following skeleton of the Rectangle class: public class Rectangle { private Point topLeft; private int height, width; public Rectangle(Point tl, int h, int w) { topLeft = tl; height = h; width = w; } public Rectangle() { this(new Point(), 0, 0); } // methods come here } 3.2.2 Explain the no-argument constructor of the Rectangle class given above. 3.2.3 Write methods for the Rectangle class to do the following: • a toString() method that returns a string of the format "top left = (x, y); height = h; width = w " where x, y, h and w are the appropriate integer values. • an above() method that tests whether one rectangle is completely above another (i.e. all y values of the one rectangle are greater than all y values of the other). For example, with the following declarations Rectangle r1 = new Rectangle(); Rectangle r2 = new Rectangle(new Point(2,2), 1, 4); the expression r2.above(r1) should give true, and r2.above (r2) should give false. (You can assume that the height of a rectangle is never negative.) (2) (5)

2425