• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

write html in jsp

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to add the last line(with the ??? infornt ) in the the jsp? i want to put that html in to the jsp line with @@@. is it possible??

<%@ 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 = 20;
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(9999);
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.");
} while(counter <24); //do
{
@@@
}
}//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");
thread1.start();
thread2.start();
%>
???<meta HTTP-EQUIV="REFRESH" content="1; url=http://localhost:8080/examples/jsp/HMC/HTML/downloaded.htm">
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To add html in jsp you need to include it in the out.println() function.

So ur line would be
out.println("<meta HTTP-EQUIV=\"REFRESH\" content=\"1; url=http://localhost:8080/examples/jsp/HMC/HTML/downloaded.htm\">");
This should work.
out.println(""); can be used to print anything in html and is used in jsp.
out is a implicit object which is used for adding html in jsp.

Cheers

niki
 
Alex Chon
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thks. what library it use??
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thatz an inbuilt support provided by JSP, no separate package
 
Alex Chon
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can't run. is shows

Generated servlet error:
[javac] Compiling 1 source file

C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\jsp\HMC\HTML\testDL_jsp.java:90: ')' expected



An error occurred at line: 7 in the jsp file: /jsp/HMC/HTML/testDL.jsp

Generated servlet error:
out.println("<meta HTTP-EQUIV="REFRESH" content="1; url=http://localhost:8080/examples/jsp/HMC/HTML/downloaded.htm">");
^



An error occurred at line: 7 in the jsp file: /jsp/HMC/HTML/testDL.jsp

Generated servlet error:
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\jsp\HMC\HTML\testDL_jsp.java:90: ';' expected



An error occurred at line: 7 in the jsp file: /jsp/HMC/HTML/testDL.jsp

Generated servlet error:
out.println("<meta HTTP-EQUIV="REFRESH" content="1; url=http://localhost:8080/examples/jsp/HMC/HTML/downloaded.htm">");

what it means??
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have nested quotes in your string literals.
You'll need to escape them or not print them from within your scriptlet.



Or
 
Alex Chon
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
haha. still can't. it shows

C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\jsp\HMC\HTML\testDL_jsp.java:93: local variable out is accessed from within inner class; needs to be declared final



An error occurred at line: 50 in the jsp file: /jsp/HMC/HTML/testDL.jsp

Generated servlet error:
out.write("<meta HTTP-EQUIV=\"REFRESH\" content=\"1; url=http://localhost:8080/examples/jsp/HMC/HTML/downloaded.htm\">");
^
 
Niki Nono
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
u need to use the method out.println()
Not out.write()
ur error is for out.write(). Check if it is the same error and confirm if it is a problem.
If it is a different error then u may need to check that u may have declared out as an object in ur JSP. Change it to something else.

I think u may have made a mistake in using the method out.println().
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try with this :

out.println("<meta HTTP-EQUIV='REFRESH' content='1; url=http://localhost:8080/examples/jsp/HMC/HTML/downloaded.htm'>");

Instead of Double Quotes use single quotes within the double quotes, as given above.
Hope this works...
-Pradeep
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why in hell are you writing directly to the outputstream anyway? Just insert the darn meta tag in your html code and the JSP compiler will do the dirty work for you.
 
He's giving us the slip! Quick! Grab this tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic