Writing JSP page and calling methods

Hello Everyone,

I'm new to java and got stuck in writing a jsp file for deploying a we app in java.

public void doReadWriteTextFile() {

String inLine = null;

StringBuffer SB = new StringBuffer();

boolean AccessionNumFound = false;

boolean SeqFound = false;

try {

BufferedReader inputStream = new BufferedReader(new

FileReader(inputFastaFleName));

while ((inLine = inputStream.readLine()) != null &&AccessionNumFound == false)

{

String acN = inLine.substring(0);

int StartPosition =acN.indexOf(">");

int EndPosition = acN.indexOf(" ");

if (StartPosition == -1 || EndPosition == -1)

{}

else

{

String accessionNumber = acN.substring(StartPosition + 1, EndPosition);

if (accessionNumber.compareTo(inputAccNumber) == 0

{

boolean NextSeqCheck = false;

System.out.println("Accession numbers matched");

System.out.println(inLine);

AccessionNumFound = true;

while ((inLine = inputStream.readLine()) != null && NextSeqCheck == false)

{

if (inLine.startsWith(">") == true)

{

NextSeqCheck = true;

}

else

{

// set a flag for future use/for rest of the processing...

SeqFound = true;

CntSequenceLines++;

SB.append(inLine);

}

}//end while+

}

}

} //end while

inputStream.close();

ProteinSequence = new String(SB);

}

catch (IOException e) {

System.out.println("IOException:");

e.printStackTrace();

}

}

public void CoverageCalculator() {

int Length =0;

String X;

for (int idx=0; idx < seqSearch.length; idx++) {

X = (seqSearch[idx]);

int startIndex = ProteinSequence.indexOf(X)+ 1;

Length = X.length();

int endIndex = Length + startIndex -1;

if(startIndex > 0){

System.out.println("Sequence: " + X +", " + " Sequence Position:" + startIndex + "-" + endIndex +", " + " Sequence Length: " + Length);

seqSearchLength = seqSearchLength + Length ;

}

else{

System.out.println("Did not find string " + seqSearch[idx]);

}

}

sequenceLength = ProteinSequence.length();

CoverageArea = (double)seqSearchLength /sequenceLength;

}

I want to call the two methods doReadWriteTextFile() andCoverageCalculator() in a jsp page.

I have written like

<%@ page import ="SequenceEditor.Core" %>

Core SeqEd = new Core();

String inputAccNumber = "UniRef100_Q3BW44";

String inputFastaFleName = "C:\\database\\unimouse-1205.fasta";

%>

<%=SeqEd.doReadWriteTextFile() %>

<%=SeqEd.CoverageCalculator() %>

but it's not working. Any help would be appreciated

[2899 byte] By [swathi_4ua] at [2007-10-2 18:44:41]
# 1
> but it's not working. Any help would be appreciatedMy brain stopped working after looking at your message. Could you post that piece of code properly using the code tags? http://forum.java.sun.com/help.jspa?sec=formatting
aniseeda at 2007-7-13 20:07:13 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

sorry about that,

public void doReadWriteTextFile()

{

String inLine = null;

StringBuffer SB = new StringBuffer();

boolean AccessionNumFound = false;

boolean SeqFound = false;

try {

BufferedReader inputStream = new BufferedReader(new FileReader(inputFastaFleName));

while ((inLine = inputStream.readLine()) != null && AccessionNumFound == false)

{

String acN = inLine.substring(0);

int StartPosition =acN.indexOf(">");

int EndPosition = acN.indexOf(" ");

if (StartPosition == -1 || EndPosition == -1)

{}

else

{

String accessionNumber = acN.substring(StartPosition + 1, EndPosition);

if (accessionNumber.compareTo(inputAccNumber) == 0)

{

boolean NextSeqCheck = false;

System.out.println("Accession numbers matched");

System.out.println(inLine);

AccessionNumFound = true;

while ((inLine = inputStream.readLine()) != null && NextSeqCheck == false)

{

if (inLine.startsWith(">") == true)

{

NextSeqCheck = true;

}

else

{

SeqFound = true;

CntSequenceLines++;

SB.append(inLine);

}

}//end while+

}

}

} //end while

inputStream.close();

ProteinSequence = new String(SB);

}

catch (IOException e) {

System.out.println("IOException:");

e.printStackTrace();

}

}

public void CoverageCalculator() {

int Length =0;

String X;

for (int idx=0; idx < seqSearch.length; idx++) {

X = (seqSearch[idx]);

int startIndex = ProteinSequence.indexOf(X)+ 1;

Length = X.length();

int endIndex = Length + startIndex -1;

if(startIndex > 0){

System.out.println("Sequence: " + X +", " + " Sequence Position:" + startIndex+ "-" + endIndex +", " + " Sequence Length: " + Length);

seqSearchLength = seqSearchLength + Length ;

}

else{

System.out.println("Did not find string " + seqSearch[idx]);

}

}

sequenceLength = ProteinSequence.length();

CoverageArea = (double)seqSearchLength /sequenceLength;

}

swathi_4ua at 2007-7-13 20:07:13 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

I want to call the two methods doReadWriteTextFile() and CoverageCalculator() in a jsp page. I have written the code like this

<%@ page import ="SequenceEditor.Core" %>

Core SeqEd = new Core();

String inputAccNumber = "UniRef100_Q3BW44";

String inputFastaFleName = "C:\\database\\unimouse-1205.fasta"; %>

<%=SeqEd.doReadWriteTextFile() %>

<%=SeqEd.CoverageCalculator() %>

but it's not working..................

swathi_4ua at 2007-7-13 20:07:13 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
> but it's not working..................What's the error message?
aniseeda at 2007-7-13 20:07:13 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Unable to compile class for JSP anddoReadWriteTextFile(SequenceEditor.Core) in SequenceEditor.Core cannot be applied to ()
swathi_4ua at 2007-7-13 20:07:13 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

> Unable to compile class for JSP

>

>and

>

> doReadWriteTextFile(SequenceEditor.Core) in

> SequenceEditor.Core cannot be applied to ()

The call you are making to the doReadWriteTextFile() method has no arguments while the message says that it expects SequenceEditor.Core as an argument.

I wonder why you have coded the class the way it is. It seems to be a strange way. By the way, are you sure you posted the correct code? Everything seems to be jumbled up.

aniseeda at 2007-7-13 20:07:13 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
yes, I did ..I'm wondering whether I made a mistake while writing the import statement....
swathi_4ua at 2007-7-13 20:07:13 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...