0% found this document useful (0 votes)
29 views3 pages

Java Dictionary Service for Synonyms

This document contains code for a dictionary web application that allows users to search for the meaning of words. It includes code for a DicService class that connects to a SQL database and queries for synonyms. It also includes code for JSP pages - index.jsp for the search form, and result.jsp to display the meaning returned from the query. The Dictionary servlet acts as the controller, taking the search term from the form, calling the DicService to get the meaning, and forwarding the result to result.jsp.

Uploaded by

aishwarriya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

Java Dictionary Service for Synonyms

This document contains code for a dictionary web application that allows users to search for the meaning of words. It includes code for a DicService class that connects to a SQL database and queries for synonyms. It also includes code for JSP pages - index.jsp for the search form, and result.jsp to display the meaning returned from the query. The Dictionary servlet acts as the controller, taking the search term from the form, calling the DicService to get the meaning, and forwarding the result to result.jsp.

Uploaded by

aishwarriya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

dicService.

java

package [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class DicService {


public String synonym (String abc) throws SQLException
{
String synonym = "";
Connection con=null;
ResultSet rs=null;
Statement stmt=null;

try {
[Link]("connected");
[Link]("[Link]");
con = [Link]("jdbc:sqlserver://[Link];" +
"databaseName=trail;user=userone;password=userone");
stmt=[Link]();
[Link]("input value"+abc);
rs=[Link]("Select * from dictionary where word = '" +abc+ "'");

while([Link]()){
[Link]("id: " + [Link]("ID"));
[Link]("word: " + [Link]("WORD"));
[Link]("meaning: " + [Link]("MEANING"));
synonym = [Link]("MEANING");
}

} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
[Link]();
}
finally{
[Link]();
[Link]();
[Link]();
}
[Link]("synonym"+synonym);
return synonym;
}
}

[Link]

<html>
<head>
<title>Convert Celsius to Fahrenheit Jsp</title>
</head>
<body>
<p align="center"><b>Dictionary service</b></p>
<form method="POST" action="Dictionary">
<p align="center"><b>Enter the word:</b>
<input type="text" name="sampleword" size="20">
<input type="submit" value="submit" name="B1"></p>
</form>
</body>
</html>

[Link]

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"


pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[Link]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Meaning</title>
</head>
<body>
<p align="center"><b>Dictionary service</b></p>
<p align="center"><b>The meaning is:</b>
<%
String name = [Link]( "meaning" ).toString();%>
<%=name%>

</body>
</html>

[Link]
package [Link];

import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
public class Dictionary extends HttpServlet
{
private static final long serialVersionUID = 1L;
public Dictionary()
{
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
{

}
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
{
try
{
String synonym = [Link]("sampleword");
[Link] stub = new [Link]();
[Link] syn = new
[Link]();
[Link](synonym);
[Link]("text/html");
PrintWriter out = [Link]();
SynonymResponse res = [Link](syn);
[Link]("Meaning "+res.get_return());
[Link]("meaning", res.get_return());
[Link]("[Link]").forward(request,response);

}
catch(Exception e)
{
[Link]();
}
}
}

You might also like