mary sarami

Greenhorn
+ Follow
since Feb 11, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by mary sarami

We have a web site that uses jsp and servlets and a database. The site consists of popup help files that are just html files. It has been suggested to put these into a database and call them from there. Is this better programmming - what is the advantages or disadvantages of this> thanks for any feedback
21 years ago
JSP
How would I code the below so that if session is null, it produces no errors.
The below doesn't produce an error but in the ncf error log it give a null 500 servlet error. but the page is fine.
Thanks
<%
String refURL = request.getHeader("referer");
out.println (refURL);
if (refURL !=null)
//if (session !=null)
if (refURL.endsWith("one.jsp") ) {
out.println("one.jsp");
%>
<jsp:forward page="one.jsp"/>

<%
} else {
out.println("seesion is null");
<% } %>
21 years ago
JSP
Simon, I did not get a chance to respond to your suggestion, concerning the code I posted, and if it should be a bean or a tag. Thanks for looking at is and your suggestions will be quite helpfull. I think I have to get your book.
Thanks
21 years ago
JSP
Hi Simon, Greetings from Canada,it sounds like your book is what I am looking for, and easy to understand.
I have some java code in my jsp page, and actually like it there, but I keep hearing about
"maintainability and reusability, it's best not to place too much Java code in your JSPs."
I haven't seen a posting of code snippets in the book givaways, but the below piece of code is what I have on my page. Is it best to put it into a tag or a bean? I should note that I have a number of these for year month and days, where the years start and end with different dates, and I use javascript for the validation.
<%
String passedBirthDateYear = (String) session.getValue("birthDateYear");
if (passedBirthDateYear==null) passedBirthDateYear="";
int birthStart = 82; // when does the years start
int birthEnd = 16; // and when do they end
String[] birthYears = new String[birthStart-birthEnd+1];
java.util.Calendar birthCal = java.util.Calendar.getInstance();
birthCal.add(java.util.Calendar.YEAR,-birthStart);
//for (int i=0;i<birthStart-birthEnd+1;i++) { //for 1920-1986
for (int i=(birthYears.length-1); i>=0; i--) { //1986-1920
birthYears[i]= String.valueOf(birthCal.get(java.util.Calendar.YEAR));
birthCal.add(java.util.Calendar.YEAR,1);
}
// Here we have an array of years from 2002-16 to 2002-82
// dob year needs to start with 1986 and end with 1920
// next year it would be 2003-17 to 2003-83
%>
---------
down in the form i have the other half
<select name="birthDateYear" tabindex="2" <% if ( secureSite != null ){ %>
class="disable" onFocus="termDtYr.focus()"
<% } else if ( display ){ %> onfocus='messageBirthDate()'<% }else{ %>
<% } %> onChange="return (isBirthDate(this.form, 'check') && allOK(this.form, 'check'));">
<OPTION >Year
<%
String ySelect1 = "";
for (int i=0;i<birthYears.length;i++) {
if (birthYears[i].equals(passedBirthDateYear)) ySelect1 = "selected";
else ySelect1 = "";
%>
<option value="<%= birthYears[i] %>"<%= ySelect1 %>><%= birthYears[i] %></option>
<%}%></select>
so what do you think?
21 years ago
JSP
I have read some reviews on this book, and even though I have accumulated many JSP books, this book it what I am looking for. We are in the final stages of the first release of a web site that uses JSP and servlets and I would like to read up on "best practices and design principles", as well as open source testing tools to validate JSP-based Web applications.
Our next release will include secure and non secure web pages. Would Model-View-Controller (MVC) be a good option for this? We have to display a different header, side nav and footer depending on if secure or not.
21 years ago
JSP
I have used the search before, was going to try a search with the tips given, and well, I cannot find the search button is.
21 years ago
It was solved by adding the following line, the french characters needs it I guess
message.setText(out1+ "\n" , "UTF-8") ;
Thanks for your reply
22 years ago
Hi,
I used the JavaMail API in a feedback form usnig JSP.
All went well,but it has been discovered that if french accents (characters) are used in the form we
get an error message:
"This message uses a character set that is not supported by the Internet Service. To
view the original message content, open the attached message. If the text doesn't
display correctly, save the attachment to disk, and then open it using a viewer that
can display the original character set."
Does something extra have to be added the the Javamail or is it a server end problem.
Any ideas?
Thanks
22 years ago
Hi,
We used the JavaMail API and JSP to set up a feedback form. All went well but we have discovered that if french accents (characters) are used in the form we
get an error message:
"This message uses a character set that is not supported by the Internet Service. To
view the original message content, open the attached message. If the text doesn't
display correctly, save the attachment to disk, and then open it using a viewer that
can display the original character set."
I am not sure if this is a OS390 problem or something that has to be added to the
JavaMail or somewhere else.
Any ideas?
Thanks
22 years ago
I was about to move to production with a site - the server was phyically moved and now some of the images don't display in netscape whereas they used to. All the images display in IE, but on someone elses PC a few of the images in IE didn't reappear.
Any ideas what could be causing this? I know more infor is most likey needed, but not sure what.
22 years ago
I am trying this two different ways and get stuck on both.
I am trying to display 2.css if the remote address is anything but 142 or 205, then I am trying to display 1.css
<%
String agent1 = request.getRemoteAddr();
if ( agent1 != null )
var style = 2.css;
else if ( agent1.startsWith("142.226.") | | agent1.startsWith("205.192."))
style = 1.css;
%>
<link rel="stylesheet" type="text/css" href="<%= style %>">
error
"jsp:28: Syntax: Unexpected symbol ignored"
and when I try it the following way I get a different error
<%
String agent1 = request.getRemoteAddr();

<% if ( agent1.startsWith("142.226.") | | agent1.startsWith("205.192.")) { %>
<link rel="stylesheet" type="text/css" href="1.css">
<%} else { %>
<link rel="stylesheet" type="text/css" href="2.css">
<%} %>
"Syntax: Unexpected input discarded"
I know my syntex is off, but how do I fix it??
22 years ago
I don't understand what you are saying is the problem.
22 years ago
I need to modify the below to be dynamic. I want to use
<%= request.getServletPath() %>
to get the url and then replace it with the opposite extension
Like intro-e.jsp - click a link and get intro-f.jsp
below is the jsp page.
<%@ page import="java.util.*" %>
<HTML lang=en>
<jsp:useBean id="toggle" class="ToggleBean" scope = "request"/>
<jsp:setProperty name="toggle" property="oldAddress" value="toggle99-e.jsp" />
<body>
<a href = "<jsp:getProperty name="toggle" property="newAddress"/>"> Click Here </a>
</body>
</html>
and this is the bean
import java.util.*;
public class ToggleBean
{
String oldAddress = null;
String newAddress = null;
public String getoldAddress()
{
return oldAddress; //method not used
}
public void setoldAddress(String str)
{
oldAddress = str;
toggleAddress();
}
public String getnewAddress()
{
return newAddress;
}
public void setnewAddress(String str)
{
newAddress = str; //method not used
}
private void toggleAddress()
{
String str = oldAddress;
if(!((str.endsWith(".htm")) | | (str.endsWith(".jsp")) | | (str.endsWith(".html"))))
{ //This program is to be used only for files names ending with .htm, .html or .jsp
newAddress= null;
return;
}

int pos = str.lastIndexOf('.');
if(pos < 0){ newAddress= null; return;}
char langCode = str.charAt(pos-1);
if(langCode =='e')
{
StringBuffer sb =new StringBuffer(str);
sb.setCharAt(pos-1,'f');
newAddress = sb.toString();
}
else
if(langCode=='f')
{
StringBuffer sb =new StringBuffer(str);
sb.setCharAt(pos-1,'e');
newAddress = sb.toString();
}
else
newAddress= null;
}
}
where would I insert <%= request.getServletPath() %> to get it set up properly
Thanks
22 years ago
I am trying to use a bean in my jsp pages.
The bean will use the getServletPath, I think.
Below is the bean to get the url. If it is a -e.jsp or a -e.html if you click the link, it should switch it to the exact page in the opposite language -f.jsp or -f.html
on my jsp page I have:
<jsp:useBean id="toggle" class="ToggleBean" scope = "request"/>
<jsp:setProperty name="toggle" property="oldAddress" value="language-e.jsp">
<a href = "<jsp:getProperty name="toggle" property="newAddress"/>Fran�ais</a>
and the ToggleBean:
import java.util.*;
public class ToggleBean
{
String oldAddress = null;
String newAddress = null;
public String getoldAddress()
{
return oldAddress; //method not used
}
public void setoldAddress(String str)
{
oldAddress = str;
toggleAddress();
}
public String getnewAddress()
{
return newAddress;
}
public void setnewAddress(String str)
{
newAddress = str; //method not used
}
private void toggleAddress()
{
String str = oldAddress;
if(!((str.endsWith(".htm")) | | (str.endsWith(".jsp")) | | (str.endsWith(".html"))))
{ //This program is to be used only for files names ending with .htm, .html or .jsp
newAddress= null;
return;
}

int pos = str.lastIndexOf('.');
if(pos < 0){ newAddress= null; return;}
char langCode = str.charAt(pos-1);
if(langCode =='e')
{
StringBuffer sb =new StringBuffer(str);
sb.setCharAt(pos-1,'f');
newAddress = sb.toString();
}
else
if(langCode=='f')
{
StringBuffer sb =new StringBuffer(str);
sb.setCharAt(pos-1,'e');
newAddress = sb.toString();
}
else
newAddress= null;
}
}
What is wrong? I get the below error.
javax.servlet.ServletException: Exception thrown running XT: Expected "" to terminate element starting on line 2.
org.xml.sax.SAXParseException: Expected "" to terminate element starting on line 2.
22 years ago
I have the following working in Tomcat and JRun, no problems works great everytime.
Then I tested it on a OS/390 system, which is where it will reside, and I am having problems.
The following is the code I am using:
String agent = request.getRemoteAddr();
// unknown clients will be internet users
String incFile = "/text/head2.html";
if ( agent != null ) {
if ( agent.length() < 1 ) {
// return content for Internet Users
incFile = "/text/head2.html";
} else if ( agent.startsWith("198.103.") | | agent.startsWith("205.192.")) {
//return content for GNET browsers
incFile = "/text/head1.html";
}
}
%>
<%-- dynamically include the file --%>
<jsp:include page="<%= incFile %>" flush="true"></jsp:include>
- on OS/390 the following works separately - but the above code does not work
<jsp:include page="/text/head1.html" flush="true"/>
<jsp:forward page="/text/head2.html"/>
I get the following message:
An error has occured while processing request:http://mvsc:8003/pbdev/m005-calculator-e.jsp
Message: Server caught unhandled exception from servlet [jsp]: Bad file argument to include
Any suggestions?
Is it possible that the file can't be found?
Is there a way to test for test?
22 years ago