Link to home
Start Free TrialLog in
Avatar of benk-master-flash
benk-master-flash

asked on

using println in a Servlet to output HTML page with button that links to another HTML page

Could somebody provide me with a quick and dirty line of code that will output
a HTML button that when clicked allows redirects the user to another page on the website.

I can use println to make webpages, but the quoting required for the HTML is problematic for me inside println(" ") statements
Avatar of sudhakar_koundinya
sudhakar_koundinya

System.out.println("<input type=button name=buttob value='Click Me'> onClick=show()");
is that what u r expecting??
Avatar of benk-master-flash

ASKER

OK - it makes the button i want it to link to http://localhost/core/index.jsp
can you make it do that
the onClick=show() syntax??? what is that?
System.out.println("<INPUT type=\"button\" name=\"TheButtonName\" value=\"Click Here\" onclick=\"doSomething()\">
and soSomething is a script to do someting you want when the button is clicked.

Hope this help you.
Bye, Giant.
System.out.println("<Script>");
System.out.println("function show(){");
System.out.println("window.location.href='http://localhost/core/index.jsp'");
System.out.println("}");
System.out.println("</Script>");

System.out.println("<input type=button name=buttob value='Click Me'> onClick=show()");
<SCRIPT language="JavaScript">
doSomething(){
window.open("http://localhost/core/index.jsp");
}
</SCRIPT>
ASKER CERTIFIED SOLUTION
Avatar of sudhakar_koundinya
sudhakar_koundinya

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for your commnets both solutions work.  I have also found the below snippet works well for servlets.
<Script> tag what language is this JavaScript or vbScript
what is a good source of reference on this topic?

String orderformURL =
              response.encodeURL("../OrderForm.jsp");
        out.println
           ("<form action=\"" + orderformURL + "\">\n" +
              "<big><center>\n" +
              "<input type=\"SUBMIT\"\n" +
              "      value=\"Return to Order Form\">\n" +
              "</center></big></form>");

>both solutions work

A split could be better.
Thanks.
And sorry for not help you.
Bye, Giant.
benk-master-flash,

If two solutions are good for you, you can split the points. Do you want me to reopen it to do this?

Venabili
Java Page Editor