HTML from JSP

Hi all,
I got a problom,
How can i get the output of a JSP page into a java class?.That is,The original JSP page sends the generated HTML to the browser.What i need is that generated HTML into a java class.
Suppose i got an Email class ,
String myContent = -------
Email.setContent(mycontent);
The string myContent should be the dynamically generated HTML from a JSP page.
that is,
String myContent = output from CustInfo.jsp.
How to achieve this?.

>
String myContent = output from CustInfo.jsp.
How to achieve this?.Open a URLConnection (or HttpURLConnection) to CustInfo.jsp,
use the getInputStream() method to get a reference to the input stream for the jsp,
read this stream (which will be the HTML for CustInfo.jsp) into the String.

Similar Messages

  • Escaping html from JSP

    I'd like to be able to run some java code, then in the middle print out a single line, then continue running the rest of my code.
    When I try escaping out of the jsp with %>, adding a <br> then returning to the jsp code with <%, it's really weird, but it seems like the jsp compiler runs ALL my code, then goes back and prints out the html.
    So
    <%
    while(condition){
    code1
    %>
    <br>
    <%
    code2
    Instead of executing code1, then printing out a line (same thing with <hr>), then doing code2, it does code1, code 2, and THEN prints out the blank line.
    Also for some reason, when I do
    PrintWriter output = response.getWriter();
    output.println("string\n");
    It ignores the line feed character and the result is no different from
    output.print("string");
    Am I doing something wrong? It shouldn't be this hard to insert a single blank line!!
    Thanks.

    Yeah, in my post I omitted the ending jsp tag. But in my actual code it's just the way you have it...there's something strange about the way the jsp compiler handles the html.
    My actual code looks like this (now you see why, for simplification I just put down code1, code2!):
    <%
    PrintWriter output = response.getWriter();
    String workdir = application.getRealPath("/")+"DA_web\\work\\";
    String monitordir = application.getRealPath("/")+"DA_web\\monitor\\";
    DiskFileUpload fu = new DiskFileUpload();
    List fileItems = fu.parseRequest(request);
    Iterator itr = fileItems.iterator();
    while(itr.hasNext()) {
    FileItem fi = (FileItem)itr.next();
    //Check if not form field so as to only handle the file inputs
    //else condition handles the submit button input
    if(!fi.isFormField()) {
    output.println("\nNAME: "+fi.getName());
    output.println("\nSIZE: "+fi.getSize());
    //System.out.println(fi.getOutputStream().toString());
                   File tempfile = new File(fi.getName());
    File fNew= new File(monitordir, tempfile.getName());
    output.println(fNew.getAbsolutePath());
                   output.println('\n');
    %>
         <hr><br>
    <%
    if (fi.getName()!=null && fi.getName().length()>0 && fi.getSize()>0)
                        fi.write(fNew);
    else {
    System.out.println("Field ="+fi.getFieldName());
    %>

  • Reading HTML from JSP

    Hi, I am currently doing an enterprise application and constructed a page using html with a link using HREF. When I click the link I run a jsp file. It there a way to read the name of the link into a string in the jsp file when the link is clicked? Please help I am still a bit green in jsp.
    Thank you.

    // I usr acceptCharset
    %@ page contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
    <html:form acceptCharset="UTF-8" action="/doSomthing">
    <html:text property=" firstname" />
    </html:form>
    in the action Action class
        Sysrem.out.println("Firsname: "+myForm.getFirstname())
       // ouput
        Firstname: ��ther is any method to it ???????

  • Referencing static html pages from jsps...

              Hi,
              This is probably a very simple thing to solve, but I'm having problems with referencing
              html pages from jsps under Weblogic.
              I get Error 404 - not found, whenever I try something like this in a JSP...
              <frame name="title" src="title.html" scrolling=no>
              The title.html file has definitely been copied into my ear file, and yet it isn't
              found. I can solve the problem by turning title.html into a jsp and registering
              it in web.xml. But this seems like serious overkill with static content!!
              Am I missing something really simple here?
              

              I've worked it out - directory mistake...
              Thanks,
              Chris
              "Matt Krevs" <[email protected]> wrote:
              >it sounds like a relative pathing problem
              >
              >is title.html reachable if you enter its address in the browser?
              >
              >is title.html in the same directory as your jsp?
              >
              >perhaps you could post your web.xml file?
              >
              >"Chris Sceats" <[email protected]> wrote in message
              >news:3d9c41b5$[email protected]..
              >>
              >> Hi,
              >>
              >> This is probably a very simple thing to solve, but I'm having problems
              >with referencing
              >> html pages from jsps under Weblogic.
              >> I get Error 404 - not found, whenever I try something like this in
              >a
              >JSP...
              >>
              >> <frame name="title" src="title.html" scrolling=no>
              >>
              >> The title.html file has definitely been copied into my ear file, and
              >yet
              >it isn't
              >> found. I can solve the problem by turning title.html into a jsp and
              >registering
              >> it in web.xml. But this seems like serious overkill with static content!!
              >>
              >> Am I missing something really simple here?
              >
              >
              

  • How to pass the value from JSP or HTML  to Applet

    Plz reply ....How can we pass the value from the JSP Page or from HTML page to Applet embedded in same page....

    Hi,
    <applet codebase = "."
    archive = foo.jar"
    code = "com.bar"
    name = "bar"
    id = "bar"
    width = "<%=Request["width"] %>"
    HEIGHT = "<%=Request["appHeight"] %>"
    hspace = "0"
    vspace = "0"
    align = "middle"
    alt     = "Applet is Loading..."
    >
         <param name="LANGUAGE"                value="<%=Request["lan"] %>">          
         <param name="LOGOUT_USER_URL"           value="EndSession.asp">
         <param name="DATA_READ_INTERVAL"      value="10000">
         <param name="REFRESH_INTERVAL"           value="5000">     
         <param name="DEFAULT_FONT"           value="Arial">
    </applet>
    pass values @ ur html or jsp page to Applet as parameters.
    Refer above code. By using getParameter() method of Applet, u can take values inside applet.

  • Create Form Beans from JSP/HTML forms

    In the Builder certification objectives, there is one called "Create Form Beans from JSP/HTML forms". How can I do that? How can I create a form beam starting from the JSP form or HTML form?

    Guys, no one from forum can answer this question?

  • Redirect from jsp bean to jsp or html page

    I am facing a problem in redirecting to a jsp page from jsp bean
    How do i redirect from jsp bean to any other page like jsp or html.
    [email protected]

    Hi
    The solution you suggested we tried it long before only but it is not feasible for us as we have to implement it in all web pages which are in thousands.
    My need is like this.
    We have given specific time to each of our registered user , as user logs to our portal we calculate session time in bean and as he logs out is new time gets updated. (its like dial up connection)
    Now what happens consider user has left only 10 minutes balance, I can calculate and keep track for his time in bean.Now as the time becomes zero I want to redirect him to home page.
    As u said i can get return value zero for bean and can do it ,but our webpages are near about thousands.

  • How to call servlet from jsp

    i m trying to call it from jsp using
    <a href="../purchaseP?orderno=<%=pno%>"><%=pno%></a>
    but its giving error..
    type Status report
    message HTTP method GET is not supported by this URL
    description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).

    i m trying to call it from jsp using
    <a href="../purchaseP?orderno=<%=pno%>"><%=pno%></a>
    but its giving error..
    type Status report
    message HTTP method GET is not supported by this URL
    description The specified HTTP method is not allowed
    for the requested resource (HTTP method GET is not
    supported by this URL).Are you implementing the doGet or doPost method in your servlet? If you are calling from a hyperlink then it needs to be implementing the GET method. To access the POST method use a html form.

  • How to call RDF report from JSP page

    Dear all,
    I want to call a RDF report from JSP page. I am creating the JSP page using j developer 10G.
    Can anyone help me out in this case. Is there any tag or procedure or any other way by of that i can perform this work.
    please help and send the reply on [email protected],[email protected]
    thanks
    Ashok

    Hi Ashok,
    You can use rwservlet - nothing really to do with JDeveloper. Once you have report server up and running (hint: read http://download-uk.oracle.com/docs/cd/B14099_19/bi.1012/b14048/toc.htm), you can call a report like this:
    http://server:port/rwservlet?report=my_report.rdf&destype=cache&desformat=html&p_my_parameter=xxx etcHope this helps,
    John

  • Crystal report from JSP using the JRC

    Hi, I am trying to call crystal report from JSP using the JRC.
    But i am getting the Error as 'Logon Failed'. my web.xml entry is
    <env-entry>
    <env-entry-name>jdbc/Test</env-entry-name>
    <env-entry-value>!oracle.jdbc.driver.OracleDriver!jdbc:oracle:thin:{userid}/{password}@//10.0.0.1:1521/TestDB</env-entry-value>
    <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>
    i am setting the userid and password in the code. Please see the below code for your reference. Please help me to solve the issue.
    <%@ page language="java" contentType="text/html;charset=UTF-8"%>
    <%@ page import="com.crystaldecisions.report.web.viewer.CrystalReportViewer"%>
    <%@ page import="com.crystaldecisions.sdk.occa.report.data.*"%>
    <%@ page import="com.crystaldecisions.reports.reportengineinterface.JPEReportSourceFactory" %>
    <%@ page import="com.crystaldecisions.sdk.occa.report.reportsource.IReportSourceFactory2" %>
    <%@ page import="com.crystaldecisions.sdk.occa.report.reportsource.IReportSource" %>
    <%@ page import="com.crystaldecisions.reports.reportengineinterface.JPEReportSource" %>
    <html>
    <head>
    <title>Crystal Report with Database Logon information</title> </head>
    <body bgcolor="#ffffff">
    <%
    try
    String report = "/TEMPLATE.rpt";
    IReportSourceFactory2 rptSrcFactory = new JPEReportSourceFactory();
    JPEReportSource reportSource = (JPEReportSource) rptSrcFactory.createReportSource(report, request.getLocale());
    CrystalReportViewer viewer = new CrystalReportViewer();
    viewer.setReportSource(reportSource);
    viewer.setHasRefreshButton(true);
    IConnectionInfo newConnInfo = new ConnectionInfo();
    newConnInfo.setUserName("TEST");
    newConnInfo.setPassword("TEST");
    ConnectionInfos newConnInfos = new ConnectionInfos();
    newConnInfos.add(newConnInfo);
    viewer.setDatabaseLogonInfos(newConnInfos);
    viewer.setEnableLogonPrompt(false);
    viewer.setOwnPage(true);
    viewer.setOwnForm(true);
    out.println("Connection Information: "+viewer.getDatabaseLogonInfos().getConnectionInfo(0).getAttributes().toString());
    viewer.processHttpRequest(request, response, getServletConfig().getServletContext(),null);
    viewer.dispose();
    catch(Exception e)
    throw new JspException( e);
    %>
    </body>
    </html>

    I never really had much luck with this approach.
    Mind you I was using Crystal Reports 10, and as far as I recall it didn't allow setting/changing of database at this level.
    Things to check
    - can you create a database connection on your page with this URL/username/password?
    - what server are you using? Tomcat? WebLogic?
    I found this in your other post:
    Connection Information: {Server Name=ee6rpt, Connection String=DSN=s(ee6rpt);User ID=s(ee62test);Password=;UseDSNProperties=b(false), Database Name=, Database DLL=crdb_odbc.dll}That would indicate it is using odbc to connect to the database (crdb_odbc.dll). ODBC is a bad idea with java.
    The way I have got it to work for me (after much trial and error) was to in Crystal Reports to connect using the Oracle Driver, and specifying a tnsname - eg define REPORT_DS in tnsnames.ora.
    When running through the JRC, it looked for a JNDI datasource under that same name "REPORT_DS".
    Don't know if that will help you or not.
    Good luck,
    evnafets

  • XML to convert creative html to jsp?

    I am trying to find a way to use XML, XSL, etc., to make the process of building web pages at my company easier between the creative team and developers:
    1.) The creative team creates the images, text, and html (using Dreamweaver). Please note, the creative team barely knows html, much less xml, xsl, or taglibs.
    2.) The creative team then sends me the html pages.
    3.) I then need to "convert" the html into jsps. That is, I remove the mock/dummy dynamic content, and replace it with the scriptlets or taglibs that will produce the real dynamic content.
    This takes alot of time. On top of that, if the creatives ever need to be changed, I need to send the newly converted jsps back to the creative team. They inevitably mess the jsps up, because they do not understand scriptlets or taglibs. Is there some standard way of dealing with this scenario, so that the creative team and I can work better together, and so that I dont constantly "convert" the html pages to jsps? I know one option is Enhydra's xmlc, but I will have a hard time getting the creative team to adopt that.
    thank you,
    David

    y don't u eliminate your jsp from your HTML. you can inculde html files as a header and footer.
    tell to write a comment tag in html <Html code> <table><tr><td> <!--jsp output--></td></tr></table> <Html code>. you can write a small jsp which can String.indexOf("<!--jsp output-->");. you can easily create header and footer files. for your jsp, u can also change your jsp code like this.

  • Can I import HTMLs from inside the project and use as portlet page ?

    As you know, I am using Java Studio Creator 2 Update 1 for my current portal project. I have created JSR-168 JSF Portlet Project for my portlet development.
    As I have some html pages ready for my development,
    Can I import HTMLs from inside the project and use as portlet page for my project?
    I did the followings steps:
    1: In side the project - File -> Add Existing Item -> Web Page ( imported test.html page from my local folder)
    2: Let it convert some of the tags for me ( so now it becomes - �test.jsp� )
    3: Set it to initial view.
    4. A default portlet page � newPortletPage.jsp is still there with no initial view.
    Now after doing this, No Visual Designer and Properties window available to for that �test.jsp� page. Though it allowed me to �build� the project successfully.
    When I build and run the portlet application, got the error message �Error occurred in portlet!� on Pluto Portal. Please advice.

    You do not open fcpproject files. You don't double click or anything else. The files have to be in the correct folder structure in the Final Cut Projects folder and the application opens them automatically. Can you post screen shots of the Final Cut Projects folder and its location.

  • Need help in writing data from JSP to excel

    Hi ,
    I need help in writing the data from JSP to excel.I somehow able to retrieve the data into excel but unable to get the required format.
    For eg: The amount should be displayed in 0.00 format .when i am exporting it to excel it is displaying as 0 :( .
    I am using the following code in JSP.
    "out.print(amt + '\t');"
    Would like to know if there is any otherway where in i can get my requirement.
    Thanks
    Tom

    Hi,
    Try using format part of the JSTL tag libs.
    Syntax :
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <fmt:formatNumber value="40" pattern="$#,##0.00"/>
    I need help in writing the data from JSP to excel.I
    somehow able to retrieve the data into excelHow do u convert the jsp to excel?
    One way to convert the jsp page to excel, is to render it as an excel appl instead of html. Set the content type of the response to application/ms-excel.
    response.setContentType("application/ms-excel")Hope this Helps....

  • How to get the form reference in .js page from .jsp page

    hi
    i have written one form in jsp page omething like:-
    <html:form action="/shopping" onsubmit="return false;">
    can anybody tell me,how to get the form reference in .js page from .jsp page ,
    i have tried:-
    var formRef = document.forms[0];
    butits not working.
    Thanks.

    Its very simple......y cant u prefer google...Bad
    c this example...
    function submit()
    alert("textbox"+ document.forms[0].name.value);//to get textbox value in js
    document.forms[0].submit();//to submit jsp page using js
    <html:html>
    <html:form action="/shopping" onsubmit="submit()">
    <html:text property=name>
    learn to search in google..
    </html:form>
    </html:html>

  • Passing value from JSP to JApplet

    Hello,
    I am stuck up with a problem, can anyone please tell me how do i pass a value from a JSP page
    to a JApplet,
    and the parameter passed through JSP should be displaed in the JTextArea.
    It would be kindful if any of you could help.
    Thanks
    Sanam

    hello,
    thanks for reply.
    I know how to pass parameters from html,
    I want to pass values from jsp page,
    and i dono how to do it, may be we cann pass values through url connection but i dono how.
    if anone knows plz help me in solving this.
    i hvae posted my applet code.
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.JToolBar;
    import javax.swing.JButton;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JTextArea;
    import javax.swing.JScrollPane;
    import javax.swing.JPanel;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import java.sql.*;
    <applet code = "DocApplet" width = 500 height =5000>
    </applet>
    public class DocApplet extends JApplet
         private JPanel jp;
         private Container cp;
         private JTextArea jt;
         private JToolBar tb;     
         private JScrollPane sp;
         private String annotation;
         private String url;
         private Connection con;
         private Statement stmt;
         public void init()
              jp = new JPanel();
              cp = getContentPane();
              jt = new JTextArea();
              tb = new JToolBar();
              sp = new JScrollPane(jt);
              repaint();
         public void start()
              jp.setLayout(new BorderLayout());
              jp.add(tb, BorderLayout.NORTH);
              jp.add(sp, BorderLayout.CENTER);
              jt.setBackground(Color.BLACK);
              jt.setForeground(Color.WHITE);
              setContentPane(jp);
              addButtons(tb);
              repaint();
         public void run()
              repaint();
         public void paint()
         private void addButtons(JToolBar tb)
              JButton button = null;
              button = new JButton("Save");
              button.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent e)
              tb.add(button);
    }

Maybe you are looking for

  • Change my itunes account and all devices to a new pc

    Hi I was wondering how I can change over everthing that has to do with my itunes to my new laptop. Me and my wife have several apple devices. We both have Iphones and 3 ipod touches plus just purchased and ipad. I have a new laptop and transfered all

  • AMD card VGA output misaligned since LTS 3.14

    Hi, since the update to Linux LTS 3.14, the VGA output of my AMD graphics card is misaligned (see image below). The graphics card is a Radeon HD 6670 (Turks XT). The digital ports, at least HDMI, are fine though. I do not really know whether it's a c

  • Auto_master, mounting afp shares without username/password in plain text?

    Hi, i'm trying to mount afp-shares from a Synology Diskststation and an Airport Time Capsule via the automountd. I've modified the /etc/auto_master as follows: # Automounter master map +auto_master            # Use directory service /net             

  • How can i install Busineess Object XI in redhat Linux?

    <p>Does BusinessObjects Enterprise XI support clustering and loadbalncing ?<br /> If YES, does it supported on Redhat Linux ?<br /> Any document or URL on this ?</p>

  • Creating Videos on Vista from my iPhone 3G S videos

    I'd like to take videos on my 3G S, Upload them to my Vista Machine, and edit / merge them to create actual movies. 1. I can't find on my PC where the videos are stored, so where are they? 2. When / if I do find them, what format will they be in? 3.