- What is a Web Service?
- What are the advantages of Web Services?
- What are different types of Web Services?
- What is SOAP?
- What are advantages of SOAP Web Services?
- What are disadvantages of SOAP Web Services?
- What is WSDL?
- What are different components of WSDL?
- What is UDDI?
- What is difference between Top Down and Bottom Up approach in SOAP Web Services?
- What is REST Web Services?
- What are advantages of REST web services?
- What are disadvantages of REST web services?
- What is a Resource in Restful web services?
- What are different HTTP Methods supported in Restful Web Services?
- Compare SOAP and REST web services?
- What are different ways to test web services?
- Can we maintain user session in web services?
- What is difference between SOA and Web Services?
- What is the use of Accept and Content-Type Headers in HTTP Request?
- How would you choose between SOAP and REST web services?
- What is JAX-WS API?
- Name some frameworks in Java to implement SOAP web services?
- Name important annotations used in JAX-WS API?
- What is use of javax.xml.ws.Endpoint class?
- What is the difference between RPC Style and Document Style SOAP web Services?
- How to get WSDL file of a SOAP web service?
- What is sun-jaxws.xml file?
- What is JAX-RS API?
- Name some implementations of JAX-RS API?
- What is wsimport utility?
- Name important annotations used in JAX-RS API?
- What is the use of @XmlRootElement annotation?
- How to set different status code in HTTP response?
Learning Path
Learning and Development.
6. Develop Servlet Question-Answer Application using HttpServletRequest and HttpServletRequest interfaces.
Index.jsp(GUI)
%@page
contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html;
charset=UTF-8">
<title>JSP Page</title>
</head> <body>
<form action="Question"
method="GET">
<h4><u><center>Check
Your
Knowledge
........</center></u></h4>
<h4>What JSP stand
for </h4>
<input
type="radio" name="q1"
value="Java Server
Pages"><b>Java Server Pages</b><br>
<input
type="radio" name="q1"
value="Java Server
Programming"><b>Java Server Programming</b><br>
<input
type="radio" name="q1" value="Java Service
Pages"><b>Java
Service Pages</b><br>
<input
type="radio" name="q1"
value="Java Service
Programming"><b>Java Service Programming</b><br>
<h4>Which of the following languages can be
used
to write server
side
scripting in ASP.NET?</h4>
<input
type="radio" name="q2"
value="C#"><b>C#</b><br> <input type="radio" name="q2"
value="VB"><b>VB</b><br>
<input
type="radio" name="q2"
value="C++"><b>C++</b><br>
<input
type="radio" name="q2"
value="Both a and b"><b>Both a and b</b><br>
<h4>What
command is used to
remove
files
in Linux?</h4>
<input
type="radio" name="q3"
value="dm"><b>dm</b><br> <input type="radio" name="q3"
value="rm"><b>rm</b><br>
<input
type="radio" name="q3"
value="delete"><b>delete</b><br>
<input
type="radio" name="q3"
value="None of the above"><b>None of the above</b><br>
<input
type="Submit" name="btnsubmit"> </form></body></html>
|
Question.java(Servlet File)
import java.io.IOException; import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import
javax.servlet.http.HttpServletResponse;
public class Question extends HttpServlet
{
protected void doGet(HttpServletRequest
request,
HttpServletResponse
response) throws ServletException, IOException
{
response.setContentType("text/html;charset=UTF-8"); int correct=0;
int
incorrect=0;
String a=request.getParameter("q1"); String b=request.getParameter("q2"); String c=request.getParameter("q3"); if(a.equals("Java Server Pages"))
{
correct++; }
else
{
incorrect++; }
if(b.equals("Both a and b")) {
correct++; }
else
{
incorrect++; }
if(c.equals("rm")) {
correct++; }
else
{
incorrect++; }
PrintWriter out = response.getWriter();
try
{
/* TODO output your page here. You may use following sample code. */ out.println("<!DOCTYPE
html>");
out.println("<html>"); out.println("<head>");
out.println("<title>Servlet Question</title>"); out.println("</head>");
out.println("<body>");
out.println("<h2>Result Of the Test</h1><br>"); out.println("<h3>Correct Answer
:::"+correct+"</h3>"); out.println("<h3>Incorrect
Answer
:::"+incorrect+"</h3>"); out.println("</body>");
out.println("</html>");
}
catch(NumberFormatException e)
{
e.printStackTrace(); }
} }
|
12. Develop a JSP Application to Authenticate User Login as per the Registration Details. If Login Success then forward User to Index Page otherwise show Login failure Message.
Listing 1: Login Form
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Login Page</h1>
<center>
<h2>Signup Details</h2>
<form action="LoginCheck.jsp" method="post">
<br/>Username:<input type="text" name="username">
<br/>Password:<input type="password" name="password">
<br/><input type="submit" value="Submit">
</form>
</center>
</body>
</html>
|
Listing 2: LoginCheck.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String username=request.getParameter("username");
String password=request.getParameter("password");
if((username.equals("anurag") && password.equals("jain")))
{
session.setAttribute("username",username);
response.sendRedirect("Home.jsp");
}
else
response.sendRedirect("Error.jsp");
%>
</body>
</html>
|
Listing 3: Home.jsp
<%@page contentType="text/html" pageEncoding="UTF-8" errorPage="Error.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<br/><br/><br/><br/><br/>
<center>
<h2>
<%
String a=session.getAttribute("username").toString();
out.println("Hello "+a);
%>
</h2>
<br/>
<br/>
<br/><br/><br/><br/><br/>
<a href="logout.jsp">Logout</a>
</center>
</body>
</html>
|
Listing 4: Logout.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
session.removeAttribute("username");
session.removeAttribute("password");
session.invalidate();
%>
<h1>Logout was done successfully.</h1>
</body>
</html>
|
Listing 5: Error.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Some Error has occured,Please try again later...</h1>
</body>
</html>
|
Subscribe to:
Posts (Atom)