[Biojava-l] Doubt
Ramana
ramana@galainfotek.com
Fri, 17 Aug 2001 11:23:36 +0530
This is a multi-part message in MIME format.
------=_NextPart_000_0009_01C1270F.0E5DB720
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hello=20
This ramana from GalaInfotek,
in follwing code you used openDb method but i did'nt find any where in
through out superclasses and implemented interfaces of =
IndexedSequenceDB.
IndexedSequenceDB.openDB(dbName)
import java.io.*;
import javax.servlet.*;
import javac.servlet.http.*;
import org.biojava.bio.symbol.*;
import org.biojava.bio.seq.*;
import org.biojava.bio.seq.io.*;
import org.biojava.bio.seq.db.*;
public class SequenceServlet extends HttpServlet {
private SequenceDB indexedDB; // Database to serve
private SequenceFormat seqFormat; // Used for writing
public void init(ServletConfig config)
throws ServletException
{
super.init(config);
String dbName =3D config.getInitParameter("sequence.db");
if (dbName =3D=3D null)
throw new ServletException("Database not specified");
try {
indexedDB =3D IndexedSequenceDB.openDB(dbName);
} catch (Exception ex) {
log("Can't open sequence database: " + dbName, ex);
throw new ServletException();
}
seqFormat =3D new FastaFormat();
}
public void doGet(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException, IOException
{
String id =3D req.getParameter("id");
if (id =3D=3D null) {
resp.sendError(HttpServletResponse.SC_NOT_FOUND,
"No id parameter in request");
return;
}
try {
Sequence seq =3D indexedDB.getSequence(id);
resp.setContentType("text/plain");
PrintStream stream =3D new PrintStream(resp.getOutputStream());
seqFormat.writeSequence(seq, stream);
} catch (BioException ex) {
log("Can't retrieve sequence", ex);
resp.sendError(HttpServletResponse.SC_NOT_FOUND,
"Couldn't load sequence " + id);
}
}
}
and one more thing
you used a class FastaDescriptionReader in some where ,but i did'nt find
this class......
can u plz check it and send the solution
bye
RAMANA
------=_NextPart_000_0009_01C1270F.0E5DB720
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2919.6307" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hello <BR>This ramana from =
GalaInfotek,<BR>in=20
follwing code you used openDb method but i did'nt find any where =
in<BR>through=20
out superclasses and implemented interfaces of =20
IndexedSequenceDB.<BR>IndexedSequenceDB.openDB(dbName)<BR><BR> impor=
t=20
java.io.*;<BR>import javax.servlet.*;<BR>import =
javac.servlet.http.*;<BR>import=20
org.biojava.bio.symbol.*;<BR>import org.biojava.bio.seq.*;<BR>import=20
org.biojava.bio.seq.io.*;<BR>import =
org.biojava.bio.seq.db.*;<BR><BR>public=20
class SequenceServlet extends HttpServlet {<BR> =
private=20
SequenceDB indexedDB; // Database to=20
serve<BR> private SequenceFormat seqFormat; // =
Used for=20
writing<BR><BR> public void init(ServletConfig=20
config)<BR> throws=20
ServletException<BR> =20
{<BR> =20
super.init(config);<BR> String dbName =3D=20
config.getInitParameter("sequence.db");<BR> if (dbName =3D=3D=20
null)<BR> throw new ServletException("Database =
not=20
specified");<BR> try {<BR> indexedDB =3D=20
IndexedSequenceDB.openDB(dbName);<BR> =
=20
} catch (Exception ex) {<BR> log("Can't open =
sequence=20
database: " + dbName, ex);<BR> throw new=20
ServletException();<BR> =20
}<BR><BR> seqFormat =3D new FastaFormat();<BR> =20
}<BR><BR> public void doGet(HttpServletRequest=20
req,<BR>  =
; =20
HttpServletResponse resp)<BR> =
throws=20
ServletException, IOException<BR> =20
{<BR> String id =3D=20
req.getParameter("id");<BR> if (id =3D=3D null) =
{<BR> =20
resp.sendError(HttpServletResponse.SC_NOT_FOUND,<BR> &nb=
sp; &nbs=
p; =20
"No id parameter in=20
request");<BR>  =
; =20
return;<BR> }<BR><BR> try {<BR> =
Sequence seq =3D=20
indexedDB.getSequence(id);<BR> =20
resp.setContentType("text/plain");<BR> =
PrintStream=20
stream =3D new =
PrintStream(resp.getOutputStream());<BR> =20
seqFormat.writeSequence(seq,=20
stream);<BR> } catch =
(BioException ex)=20
{<BR> log("Can't retrieve sequence",=20
ex);<BR> =20
resp.sendError(HttpServletResponse.SC_NOT_FOUND,<BR> &nb=
sp; &nbs=
p; =20
"Couldn't load sequence " + =
id);<BR> =20
}<BR> }<BR>}<BR>and one more thing<BR>you used a class =
FastaDescriptionReader in some where ,but i did'nt find<BR>this=20
class......<BR>can u plz check it and send the=20
solution<BR>bye<BR>RAMANA<BR></FONT></DIV></BODY></HTML>
------=_NextPart_000_0009_01C1270F.0E5DB720--