Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jsp redirect

 
Alex Chon
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error code is:
Generated servlet error:
[javac] Compiling 1 source file

C:\Program Files\Tomcat 4.1\work\Standalone\localhost\examples\jsp\HMC\HTML\testDL_jsp.java:110: '}' expected
^
C:\Program Files\Tomcat 4.1\work\Standalone\localhost\examples\jsp\HMC\HTML\testDL_jsp.java:34: 'try' without 'catch' or 'finally'
try {
^
2 errors



<%@ page import="java.io.*"%>
<%@ page import="java.lang.Thread"%>
<%@ page import="java.net.URL"%>
<%@ page import="java.net.URLConnection"%>



<%
class ThreadBase implements Runnable
{

int counter = 0;
String inStr="http://hgdownload.cse.ucsc.edu/goldenPath/hg17/vsMm5/axtNet/chr";
URL m_URL = null;
URLConnection m_URLConn = null;

public void run()

{

try
{
//thread1.join();
String x_str = "";
do{
cs();
x_str = Integer.toString(counter);
if (counter==23) x_str = "X";
else if (counter==24) x_str="Y";

m_URL = new URL(inStr+x_str+".axt.gz");
m_URLConn = m_URL.openConnection();
URLConnection uc = m_URL.openConnection();
//InputStream in = new FileInputStream(uc.getInputStream());
InputStream in = new BufferedInputStream(uc.getInputStream());
ByteArrayOutputStream bs = new ByteArrayOutputStream(30000);
int i;
String sFile = "c:\\downloadChr\\mhuman\\chr"+x_str+".axt.gz";
System.out.println("Getting file " + sFile);
File of = new File(sFile);
while(-1 != (i = in.read()))
bs.write(i);
in.close();
byte bt[] = bs.toByteArray();
FileOutputStream fos = new FileOutputStream(of);
fos.write(bt);
fos.close();
System.out.println("Thread is running.");
//x++;

} while(counter <24); //do

//String redir = request.getParameter("http://localhost:8080/examples/jsp/HMC/HTML/downloaded.ht m" );
//response.sendRedirect(redir);

RequestDispatcher disp;
disp = getServletContext().getRequestDispatcher("http://localhost:8080/examples/jsp/HM C/HTML/downloaded.htm");
disp.forward(req, resp);
return;



}//try
catch(Exception e)
{
e.printStackTrace();
}


}

private void cs()
{
int x = counter;
x=x+1;
counter = x;
System.out.println("Thread is running with Chr " + counter);
}

}


ThreadBase base = new ThreadBase();
Thread thread1 = new Thread(base, "T1");
Thread thread2 = new Thread(base, "T2");
//Thread thread3 = new Thread(base, "T3");
//Thread thread4 = new Thread(base, "T4");
thread1.start();
thread2.start();
//thread3.start();
//thread4.start();
%>

Once i put in the code below, it doesn't work, i'am not too sure why.

RequestDispatcher disp;
disp = getServletContext().getRequestDispatcher("http://localhost:8080/examples/jsp/HM C/HTML/downloaded.htm");
disp.forward(req, resp);
return;

The error code is:
Generated servlet error:
[javac] Compiling 1 source file

C:\Program Files\Tomcat 4.1\work\Standalone\localhost\examples\jsp\HMC\HTML\testDL_jsp.java:110: '}' expected
^
C:\Program Files\Tomcat 4.1\work\Standalone\localhost\examples\jsp\HMC\HTML\testDL_jsp.java:34: 'try' without 'catch' or 'finally'
try {
^
2 errors
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'try' without 'catch' or 'finally' is almost always caused by a missing curly brace somewhere in your code.

If you want more help pinpointing it, wrap your code in the UBB Code tags when posting. This will preserve indenting and make your code more readable.
Indents are especially important when searching for a missing curly brace.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic