Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-10-05
10
Medium Priority
?
444 Views
Last Modified: 2013-11-24
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
0
Comment
Question by:benk-master-flash
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12227528
System.out.println("<input type=button name=buttob value='Click Me'> onClick=show()");
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12227553
is that what u r expecting??
0
 

Author Comment

by:benk-master-flash
ID: 12227585
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?
0
Vim Reference Guide

Vim is a powerful text editor favored by many sysadmins and developers - here are some commands that you'll want to keep in your back pocket!

 
LVL 12

Expert Comment

by:Giant2
ID: 12227637
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.
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12227660
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()");
0
 
LVL 12

Expert Comment

by:Giant2
ID: 12227670
<SCRIPT language="JavaScript">
doSomething(){
window.open("http://localhost/core/index.jsp");
}
</SCRIPT>
0
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 500 total points
ID: 12227717
package org.prithvi.test;

public class Test {
  public Test() {
  }

  public static void main(String s[]) {
    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()'>");

  }
}
0
 

Author Comment

by:benk-master-flash
ID: 12228896
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>");

0
 
LVL 12

Expert Comment

by:Giant2
ID: 12234719
>both solutions work

A split could be better.
Thanks.
And sorry for not help you.
Bye, Giant.
0
 
LVL 20

Expert Comment

by:Venabili
ID: 12256509
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
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question