Solved

Cant access the request object only when using java scriplet code

Posted on 2006-06-28
1
399 Views
Last Modified: 2010-04-01
Heres my problem, Im tyring to find a clear way of doing this.  Im inhereting a massive system where the developers called jsp which then calls another jsp and then they used java scriplet code from what I have been told to read the information off the request object.  Now Im trying to modify the code to initially try to put to struts, but now have given that up for now since this would be massive regression test effort.  Does anyone know of way removing the scriplet code and replaceing with java script?  I have modified the page, but cannot for some odd reason in the javascript recognize the HTTP request object.  It only works with java scriplet code.  Then I tried using struts, then reading the request object, and its always null!!

The original code had a name of server hardcoded and now we want it dynamic.
Original
  String HISTORY_SERVER_HOST = "ABCDEFGH";

Now:
  String HISTORY_SERVER_HOST = inputBean.getHistoryServerName();

Also another question I had it seems to automatically know of the application object somehow?  How does that work?

The below code does work... but using scriptlet code... Any advice would be greatly appreciated!!


<%@ taglib uri="/WEB-INF/lib/jakarta-struts-1.0.jar" prefix="struts" %>
<%@ taglib uri="/WEB-INF/lib/jakarta-taglibs-page-1.0.jar" prefix="pg" %>
<jsp:useBean id="ArcHeaderAdaptor" scope="page" class="com.arc.adaptor.ArcHeaderAdaptor"/>
<jsp:setProperty name="ArcHeaderAdaptor" property="session" value= "<%= session %>"/>
<jsp:setProperty name="ArcHeaderAdaptor" property="request" value= "<%= request %>"/>
<%@ page import="arc.web.controller.*"%>
<html>
<head>
<jsp:useBean id="inputBean" scope="session" class="arc.web.model.JSPInputPageBean"/>

<%   //Set Context Path
      String contextPath = "";
      if(application.getServletContextName() != null){
            contextPath = "/" + application.getServletContextName();
      }else{
            contextPath = "";
      }
%>

<%
  String HISTORY_SERVER_HOST = inputBean.getHistoryServerName();
  System.out.println(HISTORY_SERVER_HOST);
  String top_menu = request.getParameter("top_menu");
  String server_name = request.getParameter("server_name");
  String server_title = "";

  if (HISTORY_SERVER_HOST.equalsIgnoreCase(server_name)) {
    server_name = "HISTORY";
  }

  if (!(server_name == null || server_name.equals(""))) {
    server_title = " (" + server_name + ")";
  }
%>
  <title>ARC - <%=inputBean.getTitle() + server_title %> - KRDC</title>
0
Comment
Question by:TheVeee
1 Comment
 
LVL 19

Accepted Solution

by:
Kuldeepchaturvedi earned 500 total points
Comment Utility
First thing first... Java script & java scriptlet inside jsp are two very different things and can not be replaced with each other...
Java Script runs on the client side while the scriptlet is executed on server side....

to answer your second question... JSP has a bunch of pre defined variabled and application is one of them...

to get the whole list of them please check out this link..

http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPIntro7.html

looks like you are new to JSP... I suggest to go thru this whole tutorial
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
In this article, I will show you HOW TO: Create your first Windows Virtual Machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, the Windows OS we will install is Windows Server 2016.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now