Maybe you can describe what you're trying to achieve. "Running from
java" is a little vague to me ...



2008/2/21 Goran Jambrović <[EMAIL PROTECTED]>:
> Hi,
>
>  i tried your advice, and it didn't help.
>
>  Regards,
>  Goran
>
> Hi,
>  You can change your eclipse setting to invoke a web browser instead of the
>  default internal one.
>  start from eclipse menu.
>  Window -> Preference -> Internet -> Web Browser
>
>  Thanks & Regards
>  David
>
>
>
>  Goran Jambrović <[EMAIL PROTECTED]>
>  02/20/2008 08:15 PM
>  Mail Size: 12872
>  Please respond to
>  "Tomcat Users List" <users@tomcat.apache.org>
>
>
>  To
>  users@tomcat.apache.org
>  cc
>
>  Subject
>  running servlet from java
>  Our Ref
>
>  Your Ref
>
>
>
>
>
>
>
>  Hi!
>
>  I would like to run a servlet(/FunPacmanServlet) from java.This servlet
>  would then show a jsp page in web browser. The problem is that the
>  contents of jsp page is shown in eclipse console, but the browser does
>  not show the page. Any idea what i'm doing wrong? I am using eclipse
>  3.2, tomcat 5.5,firefox. Does tomcat maybe need some setting up?
>
>  Best regards, Goran
>
>
>  ***************************My main servlet
>  code:****************************
>
>  import java.io.IOException;
>  import javax.servlet.ServletException;
>  import javax.servlet.http.HttpServletRequest;
>  import javax.servlet.http.HttpServletResponse;
>  import javax.servlet.RequestDispatcher;
>  import org.umb.portal.app.unimod.*;
>  import com.evelopers.unimod.*;
>  import java.util.Enumeration;
>
>  /**
>  * Servlet implementation class for Servlet: LoadPortalServlet
>  *
>  */
>  public class LoadPortalServlet extends javax.servlet.http.HttpServlet
>  implements javax.servlet.Servlet {
>
>  BqPortalEngine fsmEngine = new BqPortalEngine();
>
>  public static LoadPortalServlet startServlet = null;
>
>  private HttpServletRequest request = null;
>  private String jspName = "main/portal.jsp";
>  private String userAgent = "Mozilla 5.0";
>  private String contentType = "application/x-www-form-urlencoded";
>  private String accept =
>  
> "application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
>
>
>  private String keepAlive = "300";
>  private String host = "localhost:8080";
>  private String contentLength = "-1";
>  private String acceptLanguage= "sl,en-gb;q=0.7,en;q=0.3";
>  private String acceptEncoding= "gzip,deflate";
>  private String acceptCharset = "ISO-8859-2,utf-8;q=0.7,*;q=0.7";
>
>  public HttpServletRequest getRequest() { return request; }
>  public String getUserAgent() { return userAgent; }
>  public String getContentType() { return contentType; }
>  public String getAccept() { return accept; }
>  public String getKeepAlive() { return keepAlive; }
>  public String getHost() { return host; }
>  public String getContentLength() { return contentLength; }
>  public String getAcceptLanguage() { return acceptLanguage;}
>  public String getAcceptEncoding() { return acceptEncoding;}
>  public String getAcceptCharset() { return acceptCharset; }
>
>  public LoadPortalServlet() {
>  super();
>  }
>
>  public void init(){
>  System.out.println("START");
>
>  System.out.println("STOP");
>  }
>
>  public void doGet(HttpServletRequest request, HttpServletResponse
>  response) throws ServletException, IOException
>  {
>  // System.out.println("GLEJ:"+fsmEngine.getCounter());
>  // fsmEngine.fireEvent();
>
>  RequestDispatcher dispatcher = request.getRequestDispatcher(jspName);
>
>  System.out.println("#### Request MAIN portal servlet #####\n"
>  + request.getRequestURI() + "\n"
>  + request.getServletPath() + "\n"
>  + request.getServerPort() + "\n"
>  + request.getRemoteHost() + "\n"
>  + request.getAuthType() + "\n"
>  + request.getCharacterEncoding() + "\n"
>  + request.getContentLength() + "\n"
>  + request.getContentType() + "\n"
>  + request.getContextPath() + "\n"
>  + request.getLocalAddr() + "\n"
>  + request.getLocalName()+ "\n"
>  + request.getLocalPort()+ "\n"
>  + request.getMethod()+ "\n"
>  + request.getPathInfo()+ "\n"
>  + request.getPathTranslated()+ "\n"
>  + request.getProtocol()+ "\n"
>  + request.getQueryString()+ "\n"
>  + request.getUserPrincipal()+ "\n"
>  + request.getSession()+ "\n"
>  + request.getRequestURL()+ "\n"
>  + request.getParameter("url") +"\n" );
>
>  for (Enumeration t=request.getHeaderNames(); t.hasMoreElements();)
>  {
>  String headerName = (String) t.nextElement();
>  System.out.println ( "> #" + headerName + "#" + request.getHeader(
>  headerName ) +"#\n" );
>  }
>  System.out.println( "\n#### END ####\n" );
>
>  this.request = request;
>  this.startServlet = this;
>
>  userAgent = request.getHeader("User-Agent");
>  accept = request.getHeader("accept");
>  keepAlive = request.getHeader("keep-alive");
>  host = request.getHeader("host");
>  contentLength = request.getHeader("content-length");
>  acceptLanguage = request.getHeader("accept-language");
>  acceptEncoding = request.getHeader("accept-encoding");
>  acceptCharset = request.getHeader("accept-charset");
>  contentType =
>  
> "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
>
>
>
>  if (dispatcher != null)
>  {
>  dispatcher.forward(request, response);
>  }
>
>  }
>
>  protected void doPost(HttpServletRequest request, HttpServletResponse
>  response) throws ServletException, IOException {
>  doGet(request, response);
>  }
>  }
>
>
>  ***********************My java code (only the function &
>  imports):*********************
>
>  import java.io.IOException;
>  import com.evelopers.common.exception.SystemException;
>  import com.evelopers.unimod.runtime.context.StateMachineContext;
>  import com.evelopers.unimod.runtime.ControlledObject;
>  import com.evelopers.unimod.core.stateworks.Event;
>  import com.evelopers.unimod.runtime.*;
>  import com.evelopers.unimod.runtime.context.*;
>  import com.evelopers.common.exception.CommonException;
>  import com.evelopers.unimod.transform.xml.*;
>  import org.umb.portal.app.config.*;
>  import org.umb.portal.web.LoadPortalServlet;
>  import javax.servlet.http.HttpServletRequest;
>  import org.apache.commons.logging.LogFactory;
>  import org.apache.commons.logging.Log;
>  import java.util.List;
>  import java.util.Map;
>  import java.util.HashMap;
>  import java.util.Date;
>  import java.util.ArrayList;
>  import java.net.URL;
>  import java.net.URLConnection;
>  import java.io.*;
>  import java.net.*;
>  import javax.servlet.*;
>  import javax.servlet.http.*;
>
>  public void LoadWebPage ( StateMachineContext context )
>  {
>  LoadPortalServlet mainServlet = LoadPortalServlet.startServlet;
>
>  if ( mainServlet == null )
>  {
>  System.out.println ( "Main servlet not loaded yet ... ");
>  return;
>  }
>
>  String a = "http://localhost:8080/Bq-Portal/FunPacmanServlet";;
>
>  System.out.println("# Loading servlet ..... " + a);
>
>  java.net.URL url = null;
>  HttpURLConnection connection = null;
>
>  try
>  {
>  url = new java.net.URL(a);
>  }
>  catch (MalformedURLException e)
>  {
>  System.out.println("#ERROR:" + e.toString());
>  }
>
>  try
>  {
>  connection = (HttpURLConnection) url.openConnection();
>  }
>  catch(IOException e)
>  {
>  System.out.println("#ERROR:" + e.toString());
>  }
>
>  try
>  {
>
>  String request = "test";
>
>  connection.setRequestMethod("POST");
>  connection.setDoInput(true);
>  connection.setDoOutput(true);
>  connection.setInstanceFollowRedirects(false);
>
>  connection.setRequestProperty("host", mainServlet.getHost());
>  connection.setRequestProperty("accept", mainServlet.getAccept());
>  
> connection.setRequestProperty("accept-language",mainServlet.getAcceptLanguage());
>
>
>  
> connection.setRequestProperty("accept-encoding",mainServlet.getAcceptEncoding());
>
>
>  connection.setRequestProperty("accept-charset",
>  mainServlet.getAcceptCharset());
>  connection.setRequestProperty("user-agent", mainServlet.getUserAgent() );
>  connection.setRequestProperty("keep-alive", mainServlet.getKeepAlive() );
>  connection.setRequestProperty("content-length",
>  mainServlet.getContentLength() );
>  connection.setRequestProperty("content-type",
>  mainServlet.getContentType() );
>
>  connection.setAllowUserInteraction(true);
>
>  DataOutputStream out = new DataOutputStream(connection.getOutputStream());
>  out.writeBytes(request);
>  out.flush();
>  out.close();
>
>  BufferedReader reader = new BufferedReader ( new InputStreamReader (
>  connection.getInputStream()));
>  String response = reader.readLine();
>  while(null != response)
>  {
>  System.out.println(response);
>  response = reader.readLine();
>  }
>
>  }
>  catch (IOException e)
>  {
>  System.out.println("#Exception: " + e.toString());
>  }
>
>  System.out.println ( "SET URL HOST " + url.getHost());
>
>  connection.disconnect();
>
>
>  ---------------------------------------------------------------------
>  To start a new topic, e-mail: users@tomcat.apache.org
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>  -----------------------------------------
>  ******************************************************************
>  This message originated from the Internet.  Its originator may or
>  may not be who they claim to be and the information contained in
>  the message and any attachments may or may not be accurate.
>  ******************************************************************
>
>
>
>  ************************************************************
>  HSBC Software Development (Guangdong) Limited
>  whose office address is
>  5/F Jie Tai Plaza, 218 - 222 Zhong Shan Liu Road, Guangzhou,
>  The People's Republic of China
>  ************************************************************
>
>
>  -----------------------------------------
>  *******************************************************************
>  This e-mail is confidential. It may also be legally privileged.
>  If you are not the addressee you may not copy, forward, disclose
>  or use any part of it. If you have received this message in error,
>  please delete it and all copies from your system and notify the
>  sender immediately by return e-mail.
>
>  Internet communications cannot be guaranteed to be timely,
>  secure, error or virus-free. The sender does not accept liability
>  for any errors or omissions.
>  *******************************************************************
>  "SAVE PAPER - THINK BEFORE YOU PRINT!"
>
>
>  __________ NOD32 2891 (20080221) Information __________
>
>  This message was checked by NOD32 antivirus system.
>  http://www.eset.com
>
> ---------------------------------------------------------------------
>  To start a new topic, e-mail: users@tomcat.apache.org
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>

Reply via email to