Insert an anchor in jsp
Hello !
I would insert an anchor in a jsp to view it on particular place.
I've inserted in "page.jsp" :<a name="test"/>
I called my jsp in JSPDynPage like :
"page.jsp#test"
But it doesn't work...
Could you help me please ?
Thanks.
Delphine.
Hi,
You insert something like this somewhere in your jsp:
<script language="Javascript">
function somemethod() {
this.location.href='someurl#someanchor';
</script>
It is not tested.
If you have Javascript errors, look for a yellow triangle in the left bottom of your screen (double click it). In Firefox there is a javascript console.
Some Javascript resources/references:
www.w3schools.com/js/default.asp
javascript-reference.info
javascript.about.com/od/reference
Good luck,
Roelof
Message was edited by: R. Knibbe
Similar Messages
-
Hi,
I am using WebLogic 11g.
In my application am getting following exception in my console
####<Jun 4, 2012 2:03:47 AM CDT> <Error> <HTTP> <cuscmas1.hillscte.com> <AdminServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1338793427049> <BEA-101017> <[ServletContext@2141448872[app:amsatms module:/paws path:/paws spec-version:null]] Root cause of ServletException.
javax.servlet.jsp.JspException: Can't insert page '/common/MenuFiles.jsp' : Connection reset
at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.processException(InsertTag.java:956)
at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:884)
at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:473)
at jsp_servlet._tdms._common.__tdmspage._jsp__tag1(__tdmspage.java:530)
at jsp_servlet._tdms._common.__tdmspage._jspService(__tdmspage.java:427)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
Previously I was used OC4J, in that I didnt get any error.
My MenuFiles.jsp is
<%@ page import="com.hillspet.atms.common.constants.IATMSConstants" %>
<%@ page import="com.hillspet.atms.common.constants.AnimalConstants" %>
<%@ page import="com.hillspet.atms.common.constants.IATMSAccessConstants" %>
<%@ page import="com.hillspet.atms.collectionkit.util.ICollectionKitConstants" %>
<%@ page import="com.cte.common.IConstants" %>
<%@ page import="com.cte.common.dto.UserDTO,com.hillspet.atms.common.util.ATMSUtil" %>
<%@ page import="java.util.ArrayList" %>
<%@page import="com.hillspet.ahms.animal.util.IAHMSAccessConstants,com.hillspet.admin.common.util.HillspetUtil, com.hillspet.ahms.animal.dto.AnimalBaseDTO"%>
<%@page import="com.hillspet.ahms.animal.util.IAHMSAccessConstants,com.hillspet.admin.common.util.HillspetUtil, com.hillspet.ahms.animal.dto.AnimalBaseDTO"%>
<%@ page import="com.cte.common.dto.UserDTO, com.cte.common.IConstants, com.hillspet.admin.common.util.HillspetUtil, java.util.ArrayList, com.cte.common.ums.dto.RoleListEntryDTO,java.util.Arrays,java.util.Collections"%>
<%@page import="com.hillspet.tdms.common.util.ITLMSAccessConstants,com.hillspet.admin.common.util.HillspetUtil"%>
<%
boolean isInternal = false;
if(session.getAttribute("ANIMAL_BASE_DTO")!=null ){
AnimalBaseDTO animalSummaryDetailsDTO = (AnimalBaseDTO) session.getAttribute("ANIMAL_BASE_DTO");
if(animalSummaryDetailsDTO.getIsExternal()==0){
isInternal = true;
%>
<%
UserDTO dto = (UserDTO) session.getAttribute(IConstants.USER_OBJECT);
ArrayList userPermissionsList = dto.getUserPermissionList();
boolean isAdmin = dto.getRoleList().contains("" + IATMSConstants.ATMS_ADMIN_ROLE_ID);
//System.out.println("User Permission list is :" + dto.getUserPermissionList());
java.util.ArrayList rolesList = dto.getRoleList();
boolean isEUUser = HillspetUtil.checkEUAccess(request, dto);
ArrayList atmsRolesList=new ArrayList(Arrays.asList ("126","125","109","108","107","106","105","114","103","102","101","100","99","98","97","96","95","93","90","89","88","87","86","67","111","85","83","73","84","116","113", "127","128","130","132","133","134","135","136"));
boolean displayATMSMenus = !Collections.disjoint(rolesList, atmsRolesList);
%>
<script>
var breadcrumb = "<%=IATMSConstants.SEARCH_AND_VIEW%>";
Initialize and render the MenuBar when its elements are ready
to be scripted.
YAHOO.util.Event.onContentReady("vmenu", function () {
Instantiate a MenuBar: The first argument passed to the
constructor is the id of the element in the page
representing the MenuBar; the second is an object literal
of configuration properties.
var oMenuBar = new YAHOO.widget.MenuBar("vmenu", {
autosubmenudisplay: true,
hidedelay: 750,
lazyload: true });
Define an array of object literals, each containing
the data necessary to create a submenu.
var aSubmenuData = [
<%
if(rolesList.contains("67") || rolesList.contains("84") || rolesList.contains("118") || rolesList.contains("111") || rolesList.contains("90") || rolesList.contains("83") || rolesList.contains("85") || rolesList.contains("88") || rolesList.contains("82") || displayATMSMenus){
%>
id: "Tab1",
itemdata: [
<%if(HillspetUtil.checkAccess(request,IAHMSAccessConstants.CREATE_ANIMNAL_PERMISSION)) {%>
{ text: "Add Animal", url: "addAnimalGeneralInfoAction.do" },
<%}%>
<%if(HillspetUtil.checkAccess(request,IAHMSAccessConstants.CREATE_ANIMNAL_PERMISSION)) {%>
{ text: "Record Manual Feeding", url: "saveChangeDietAction.do?command=view",disabled:true },
<%}%>
<%if(HillspetUtil.checkAccess(request,IAHMSAccessConstants.SEARCH_ANIMNAL_PERMISSION)) {%>
{ text: "Search Animals", url: "animalSearchAction.do?command=view" },
<%}%>
<%if(HillspetUtil.checkAccess(request,IAHMSAccessConstants.SEARCH_IMAGES)) {%>
{ text: "Search Images",url: "animalImageSearchAction.do?command=view" },
<%}%>
<%if(HillspetUtil.checkAccess(request,IAHMSAccessConstants.SEARCH_IMAGES)) {%>
{ text: "Capture Images",url: "captureImageAction.do?command=view" },
<%}
if(!rolesList.contains("95") && !rolesList.contains("98")){ %>
{ text: "Animal Panels", url: "animalpanelList.do?command=view&searchFlag=fromMenu" },
<% }
if (dto.getUserPermissionList().contains(
AnimalConstants.AR_RECOMMEND_ANIMALS_PERMISSION)|| dto.getUserPermissionList().contains(
AnimalConstants.AR_VIEW_LIST_OF_RECOMMENDATION_PERMISSION)) {
%>
{ text: "Animal Recommendation",
submenu: {
id: "subtab11",
itemdata: [
<%
if (dto.getUserPermissionList().contains(AnimalConstants.AR_RECOMMEND_ANIMALS_PERMISSION)) {
%>
{ text: "Recommend Animals", url: "recommendedAnimal.do?command=view" },
//{ text: "Reserve / Un-reserve", url: "../ATMS/reserveUnreserve.html"},
<%}%>
<%
if (dto.getUserPermissionList().contains(
AnimalConstants.AR_RECOMMEND_ANIMALS_PERMISSION)|| dto.getUserPermissionList().contains(
AnimalConstants.AR_VIEW_LIST_OF_RECOMMENDATION_PERMISSION)) {
%>
{ text: "View Recommendations", url: "recommendedAnimalList.do?command=view"},
<%}%>
<%} else {%>
{ text: "Animal Recommendation", url: "#" , disabled: true},
<%}%>
{ text: "Move Animal",
submenu: {
id: "subtab15",
itemdata: [
<% if( isInternal ){%>
{ text: "Change Location", url: "manageAnimalLocationAction.do?command=viewHistory" },
<%}%>
<%if(HillspetUtil.checkAccess(request,IAHMSAccessConstants.ANML_DISPOSITION_PERMISSION)) {%>
{ text: "Adoption Record", url: "animalDispositionAction.do?command=view" },
<%}%>
id: "Tab2",
itemdata: [
<%if(HillspetUtil.checkAccess(request,IAHMSAccessConstants.SCHEDULE_FMT)) {%>
{ text: "Schedule Facility Maintenance Task ", url: "scheduleFMTActionForward.do?command=forward", disabled: false },
<%}%>
<%if(HillspetUtil.checkAccess(request,IAHMSAccessConstants.SCHEDULE_GROUP_TASK) || rolesList.contains("99")) {%>
{ text: "Schedule Task", url: "groupTaskSearchAction.do?command=view" },
<% } %>
{ text: "Daily Task List",
submenu: {
id: "subtab21",
itemdata: [
{ text: "Animal Care Task", url: "viewDailyTaskListAction.do?command=view&id=1&actSubTab=1"},
<%if(userPermissionsList.contains(IATMSConstants.SMCL_VIEW_SAMPLES)){%>
<%if(userPermissionsList.contains(IATMSConstants.SMCL_VIEW_SAMPLES)){%>
{ text: "Test Collections", url: "viewSMSmpleCollections.do?command=view&identifier=fromMenu" },
<% } %>
<%if(userPermissionsList.contains(IATMSConstants.SMCL_VIEW_SAMPLES)){%>
{ text: "Health Collections", url: "viewBioHealthSmplCollections.do?command=view&identifier=fromMenu" },
<%}%>
<%}%>
<%if(HillspetUtil.checkAccess(request,IAHMSAccessConstants.DAILY_TASK_LIST_MEDICAL_TESTS)) {%>
{ text: "Medical Test", url: "viewDailyTaskListAction.do?command=view&id=2"},
<%}%>
<%if(HillspetUtil.checkAccess(request,IAHMSAccessConstants.DAILY_TASK_LIST_MEDICAL_EXAMS)) {%>
{ text: "Medical Exams", url: "viewDailyTaskListAction.do?command=view&id=3"},
<%}%>
{ text: "Status Phenotype", url: "viewDailyTaskListAction.do?command=view&id=6"},
{ text: "Surgery/Procedure", url: "viewDailyTaskListAction.do?command=view&id=4"},
{ text: "Facility Maintenance ",submenu: {
id: "subtab777",itemdata: [
{ text: "Facility Maintenance Task",url: "viewDailyTaskListAction.do?command=view&id=5" },
{ text: "Search FMT Images",url: "searchFMTImageAction.do?command=view" }]
{ text: "Record Group ACTs", url: "RecordWeightFecalScoreAction.do?command=view"},
{ text: "Administer Medication", url: "recordMedicationAdministrationAction.do?command=forward" },
<%if(HillspetUtil.checkAccess(request,IAHMSAccessConstants.RECORD_OBSERVATION_PERMISSION)) {%>
{ text: "Observations",
submenu: {
id: "subtab222",
itemdata: [
{ text: "Search Observations",url: "recordObservationsAction.do?command=view" },
{ text: "Record Observations",url: "addAnimalObservationAction.do?command=add&page=record&source=monitor" },
<%}%>
{ text: "Shared Feed Diet Assignment", url: "RecordWeightFecalScoreAction.do?command=viewDefaultDiet" },
<%if(HillspetUtil.checkAccess(request,IATMSAccessConstants.TRCL_PRINT_LABELS_LIST) || HillspetUtil.checkAccess(request,IATMSAccessConstants.HRCL_PRINT_LABELS_LIST)) {%>
{ text: "Print Labels",
submenu: {
id: "subtab211",
itemdata: [
<%if(HillspetUtil.checkAccess(request,IATMSAccessConstants.TRCL_PRINT_LABELS_LIST)) {%>
{ text: "Test Collections", url: "printLabelsAction.do?command=viewTests"},
<%}%>
<%if(HillspetUtil.checkAccess(request,IATMSAccessConstants.HRCL_PRINT_LABELS_LIST)) {%>
{ text: "Health Collections", url: "printLabelsAction.do?command=viewHealthCols"},
<%}%>
<%}%>
//{ text: "Controlled Drug Inventory", url: "#" , disabled: true},
<%}%>
<%if(HillspetUtil.checkAccess(request,IATMSAccessConstants.SM_RECIEVE_SAMPLES )||
HillspetUtil.checkAccess(request,IATMSAccessConstants.SM_RECIEVE_HEALTH_SAMPLES) || dto.getRoleList().contains("85") || dto.getRoleList().contains("111") || !dto.getRoleList().contains("123") && !dto.getRoleList().contains("82") ) {%>
id: "Tab3",
itemdata: [
{ text: "Sample Management",
submenu: {
id: "subtab41",
itemdata: [
<%if(HillspetUtil.checkAccess(request,IATMSAccessConstants.SM_RECIEVE_SAMPLES )||
HillspetUtil.checkAccess(request,IATMSAccessConstants.SM_RECIEVE_HEALTH_SAMPLES) || dto.getRoleList().contains("85") || dto.getRoleList().contains("111") || !dto.getRoleList().contains("131") ) {%>
{ text: "Samples Pending Receipt",
submenu: {
id: "subtabRecieve",
itemdata: [
<%if(HillspetUtil.checkAccess(request,IATMSAccessConstants.SM_RECIEVE_SAMPLES)) {%>
{ text: "Biological Test Collections", url: "fetchLabLocationDetailsAction.do?command=forward" , disabled: false},
<%}%>
<%if(HillspetUtil.checkAccess(request,IATMSAccessConstants.SM_RECIEVE_HEALTH_SAMPLES) || dto.getRoleList().contains("85") || dto.getRoleList().contains("111")) {%>
{ text: "Biological Health Collections", url: "recieveTestSamplesAction.do?command=forward" , disabled: false},
<%}%>
<%if(!dto.getRoleList().contains("706")) {%>
{ text: "Non Biological Collections", url: "receiveNonBiologicalSamplesAction.do?command=viewNBSamples"}
<% } %>
<%}%>
<%
if(HillspetUtil.checkAccess(request,IATMSAccessConstants.LAB_SM_VIEW_RECEIVED_NON_BIO_SMPLS)||HillspetUtil.checkAccess(request,IATMSAccessConstants.SM_RECIEVED_HEALTH_SAMPLES) || HillspetUtil.checkAccess(request,IATMSAccessConstants.SM_RECIEVED_TEST_SAMPLES) || dto.getRoleList().contains("85") || dto.getRoleList().contains("111")) {%>
{ text: "Samples Received",
submenu: {
id: "subtabRecieved",
itemdata: [
<%
if(HillspetUtil.checkAccess(request,IATMSAccessConstants.SM_RECIEVED_TEST_SAMPLES) || dto.getRoleList().contains("85") || dto.getRoleList().contains("111")) {%>
{ text: "Biological Test Collections", url: "recievedTestSamplesAction.do?command=forward" , disabled: false},
<%}%>
<%
if(HillspetUtil.checkAccess(request,IATMSAccessConstants.SM_RECIEVED_HEALTH_SAMPLES) || dto.getRoleList().contains("85") || dto.getRoleList().contains("111") ) {%>
{ text: "Biological Health Collections", url: "receivedBioTestSamplesAction.do?command=forward" , disabled: false},
<%}%>
<%
if(HillspetUtil.checkAccess(request,IATMSAccessConstants.LAB_SM_VIEW_RECEIVED_NON_BIO_SMPLS) ) {%>
{ text: "Non Biological Collections", url: "receivedNonBiologicalSamplesAction.do?command=viewNBSamples"}
<%}%>
<%}%>
<%if(HillspetUtil.checkAccess(request,"VIEW_SAMPLE_BATCHES") || dto.getRoleList().contains("85") || dto.getRoleList().contains("111")||dto.getRoleList().contains("706")) {%>
{ text: "Sample Batches", url: "viewSampleBatches.do?command=view" , disabled: false},
<%}%>
<% if (dto.getUserPermissionList().contains("OUTSIDE_LAB_SAMPLES_LIST") || dto.getRoleList().contains("131") || dto.getRoleList().contains("706")){ %>
{ text: "External Lab Samples", url: "outsideLabSamplesAction.do?command=view" , disabled: false},
<% } %>
<%
if (dto.getUserPermissionList().contains(
ICollectionKitConstants.GENERATE_CK_TEMPLATE) ) { %>
{ text: "Sample Collection Kits",
submenu: {
id: "subtab421",
itemdata: [
<%
if (dto.getUserPermissionList().contains(
ICollectionKitConstants.GENERATE_CK_TEMPLATE)){ %>
{ text: "Generate Collection Kits", url: "ckCreateTemplateAction.do?command=goToGenerateCkKits" , disabled: false},
<% } %>
<%
if (dto.getUserPermissionList().contains(
ICollectionKitConstants.GENERATE_CK_TEMPLATE) ){ %>
{ text: "Search & View", url: "ckCreateTemplateAction.do?command=goToCKSearch&fromMenu=true" },
<%}%>
<%}%>
<%if(HillspetUtil.checkAccess(request,IATMSAccessConstants.SMIN_VIEW_SAMPLE_INVENTORY) ||
HillspetUtil.checkAccess(request,IATMSAccessConstants.VIEW_FORMULA_INVENTORY) || dto.getRoleList().contains("85") || dto.getRoleList().contains("111") || dto.getRoleList().contains("131")) {%>
{ text: "Sample Information",
submenu: {
id: "subtabSampleInventory",
itemdata: [
<%if(HillspetUtil.checkAccess(request,IATMSAccessConstants.SMIN_VIEW_SAMPLE_INVENTORY) || dto.getRoleList().contains("85") || dto.getRoleList().contains("111")) {%>
{ text: "Biological Samples", url: "sampleInventoryAction.do?command=view" , disabled: false},
<%}%>
<%if(HillspetUtil.checkAccess(request,IATMSAccessConstants.VIEW_FORMULA_INVENTORY)) {%>
{ text: "Non Biological Samples", url: "viewInventory.do?command=view&fromLab=Y" , disabled: false},
<%}%>
<% if ( HillspetUtil.checkAccess(request,"PENDING_ANALYSIS_REQUEST_LIST") ||
HillspetUtil.checkAccess(request,"PENDING_ANALYSIS_REQUEST_READ") ) {
%>
{ text: "Collected Samples New Request", url: "pendingAnalysisReqAction.do?command=view" , disabled: false },
<%}%>
<%}%>
]Hi,
actually this mapping only identifies those requests to be handled by teh JSF servlet. Its not a redirect.
I see several namespace definitions in your page, but no taglib reference. Wondering how this is supposed to work
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces/html" prefix="afh"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>
I assume the next crash you will see is when you add JSF components to
<f:view>
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=windows-1252"/>
<title>tt</title>
</head>
<body><h:form></h:form></body>
</html>
</f:view>
Note that mixing HTML elements with JSF is not a recommended approach
Frank -
Efficient, repetitive insertion of anchored objects
I'm using InDesign 5.5 on a Mac running OS 10.8.5 if that has anything to do with this issue. My proficiency with Id is relatively low, but I've learned how to format books and have published three of my own, am trying to finish up a fourth, and have done another for a writer friend. Here's the problem I cannot seem to solve:
At the start of every chapter I have the heading defined in a style, then a chapter graphic style, then the first paragraph of the main body in another style. I have some notes from the last time I did this a couple of years ago, and they indicate that I found a work flow that allowed me to:
1. With a chapter graphic positioned exactly where I want, copy it. What I expected to happen this time based on my previous experience was for this to copy not only the graphic, but the anchored position information as well.
2. Place the insertion point to the right of the next chapter heading and hit return.
3. With the chapter graphic set as the next style, the insertion point is now sitting where I want the graphic.
4. Paste the graphic and it's positioned where I want it.
5. Repeat this for each chapter without too much trouble.
But this time, two things happen that I'd like to avoid: 1) The graphic inserts with the right edge of the bounding box lined up with the centered insertion point, and 2) the text in the first paragraph is shoved down the page. I think what's happening is that the chapter graphic style is displaced so it's like I hit a return with that style active and I get two of them rather than the one I want.
I've been able to anchor the graphics by clicking on them with the Selection tool, then option clicking on the anchor to bring up the anchored object window, which never shows above or below line. I select that, have to change from left to center, then adjust the below spacing to get the distance I want between the bottom of the graphic and the first line of text, then change the extra chapter graphic style below the graphic to the main body style, and reposition the first paragraph where it needs to start.
Needless to say, this is going to get very old doing all that for 34 chapters, then repeat the process for a smaller graphic I'm using at every scene break, and there's a lot more of those.
I hope I've described this so that it makes sense, and I'd appreciate knowing how to solve it. Thank in advance,
Tosh
P.S. Hello Peter!Thank you for the reply. I've taken 5 screenshots to illustrate what's happening:
#1 is shows the text insertion point in the chapter graphic style between the chapter heading and the first paragraph:
#2 is the result of pasting in the graphic: What I've been able to do before (at least that's what my notes day) is to have the graphic centered on the insertion point. But you can see how the insertion point has shifted to the left, and the right edge of the graphic is lined up with it.
#3 shows application of the object style. This is a step I hadn't been doing before, and it definitely saves time not having to use the options window to set above line/center/and above values.
#4 illustrates the extra spacing between the graphic and the first paragraph because the insertion point is in the chapter graphic style, not the style for the first paragraph. Especially confusing is that the chapter graphic style is centered, and the insertion point is justified left
#5 shows the application of the first paragraph style to the location of the insertion point.
This is the result I'm looking for, and as mentioned earlier, I remember having a workflow that allowed me to paste the graphic into the centered paragraph style and that's where it stayed.
I can do this longer workflow and get what I want, but it's labor intensive and there has to be a better way.
Tosh -
Insert from button in jsp page
hi, im new o jso and needto make an insert frim a jsp page with a button,
what should i do?
i made a javascript function but i really dont know if am i right and then i tried to call this function from the html tag
beside this i execute de query from java and it was success!!, but i dont know what is wrong when i try from the jsp page with de button, please help!
thx!
here it's my code:
<script type="text/javascript">
import java.sql.*;
function Agregar()
return
StringBuffer sb = new StringBuffer();
try{
Class.forName("org.postgresql.Driver");
Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/Prueba","postgres","hola");
Statement stmt = conn.createStatement();
stmt.executeUpdate("INSERT INTO tbl_responsable (cedula,nombre,direccion) VALUES (14021752,'carlos','caracas')");
}catch(Exception e){
System.out.println("EXPLOTO");
</script>
ahora en el html que debo hacer??, o si tengo q hacer otra cosa???
html del boton:
<input type="submit" value="Agregar" action="Agregar()">
what should i do, what its wrong??
thx again!try this
<input type="submit" onclick=" return Agregar();">
or
<input type="submit" onclick=" Agregar();"> -
Inserting multiple records in JSP and setting date format
Hi,
I'm looking at the possibilities for using JSP's as a web application.
I've got a few questions about it:
1) Is it possible to insert multiple records in the detail block of my JSP. Normally when I click the 'insert button', an insert JSP comes up, which is a html form with the possiblity of inserting only one record.
2) Is it possible to change the format of a date field. Now a date field is displayed as 'YYYY-MM-DD'. My nls_date_format is something else.
3) I can't get the static combo box working for the class EditCurrentRecord. The normal use combo box is no problem. Probably, I don't have the syntax correct. Could anyone provide an example for this.2) Just use the Calendar object. You can format the date any way you want. I am assuming that you are talking about how the date appears after a .toString() call.
Here is how I do it (this code will probably look very bad I am trying to type into a very small space so bear with me):
public static String traceDate(java.sql.Timestamp dt)
try
if (dt == null)
return " ";
else
Calendar clFmt = Calendar.getInstance();
clFmt.setTime(dt);
return
String.valueOf(clFmt.get(Calendar.MONTH) + 1) + "/" +
String.valueOf(clFmt.get(Calendar.DAY_OF_MONTH)) + "/" +
String.valueOf(clFmt.get(Calendar.YEAR)) + " " +
String.valueOf( (clFmt.get(Calendar.HOUR) == 0) ? 12 : clFmt.get(Calendar.HOUR) ) + ":" +
padLt(String.valueOf(clFmt.get(Calendar.MINUTE)),2) + ":" +
padLt(String.valueOf(clFmt.get(Calendar.SECOND)),2) + " " +
(clFmt.get(Calendar.AM_PM) == Calendar.AM ? "AM" : "PM");
catch (Exception e)
throw new RuntimeException(e.getMessage());
(padLt is a custom function that just pads 0s to the left of the number) -
Inserting date from a jsp into sql server 2005 database
Dear Friends.,
i have a jsp page, in that there is a form with various user input fields. in that one field is date field. i tried to insert the date field into the sql server 2005 database. but it is not getting inserted into the database.
when i tried by inserting one field to database, it is getting inserted. for all the fields its works fine, except the date field.
i need hint or code to insert the date get from the jsp page to database.
i am using a servlet to do all database related things. i.e making connections, executing prepared statement queries
thanks
sekar.The variable needs to be outside of the string to be recognized as a variable. You need to remove the variable from the string, then concatinate it onto the string (and concatinate any remaining string parts - the closing paren). For example:
stmt.executeUpdate("INSERT INTO table VALUES ('test', " + companyID + ")");
Hope that's clear enough and helps. Good luck on your thesis!
jim -
Prob: inserting Long value withjh JSP. PLZ Help
i am doing a project in JSP and Oracle and i am very new to JSp
i am passing a 13 digit number from a main page at the back end page
text box name is "txtIsbn"
i have to store that value to oracle
pst=con.prepareStatement("insert into ISBNTABLE values(?,?,?,?)");
pst.setLong(1,Long.parseLong(request.getParameter("txtisbn")));and my database table has the field
isbn number(13)
while operation iam getting this exception
exception
org.apache.jasper.JasperException: Exception in JSP: /checkBookAcc.jsp:80
77: if(!isbnPresent)
78: {
79: pst=con.prepareStatement("insert into ISBNTABLE values(?,?,?,?)");
80: pst.setLong(1,Long.parseLong(request.getParameter("txtisbn")));
81: pst.setString(2,request.getParameter("txtBookTitle"));
82: pst.setString(3,request.getParameter("txtAuthor"));
83: pst.setString(4,request.getParameter("txtPublisher"));
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NumberFormatException: null
java.lang.Long.parseLong(Unknown Source)
java.lang.Long.parseLong(Unknown Source)
org.apache.jsp.checkBookAcc_jsp._jspService(org.apache.jsp.checkBookAcc_jsp:130)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)i checked that again after your reply in my code text box name was "txtisbn" but in the post i have written "txtIsbn"
Well i havechanged my whole thing doing all my experiments still i am getting trouble plese have a look
my text box name is txtIsbn now
my JSP page
temp=Long.parseLong(request.getParameter("txtIsbn"));
temp1=request.getParameter("txtBookTitle");
temp2=request.getParameter("txtAuthor");
temp3=request.getParameter("txtPublisher");
out.println("Value of isbn :"+temp+" Title :"+temp1);
// above statement is printing values if i comment try
while(rst.next())
if(rst.getLong("ISBN")==temp)
isbnPresent=true;
break;
//if "yes" no need to store the Isbn details if "No" add details
try{
if(!isbnPresent)
pst=con.prepareStatement("insert into ISBNTABLE values(?,?,?,?)");
pst.setLong(1,1);
pst.setString(2,temp1);
pst.setString(3,temp2);
pst.setString(4,temp3);
pst.executeUpdate();
catch (SQLException sqle)
out.println("Exception occured :"+sqle);
}if i dont comment the try the Exceptions comes like that
org.apache.jasper.JasperException: Exception in JSP: /chkIsbn.jsp:62
59: if(!isbnPresent)
60: {
61: pst=con.prepareStatement("insert into ISBNTABLE values(?,?,?,?)");
62: pst.setLong(1,1);
63: pst.setString(2,temp1);
64: pst.setString(3,temp2);
65: pst.setString(4,temp3);
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:703)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:670)
org.apache.jsp.checkBookAcc_jsp._jspService(org.apache.jsp.checkBookAcc_jsp:106)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
javax.servlet.ServletException: General error
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.chkIsbn_jsp._jspService(org.apache.jsp.chkIsbn_jsp:130)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:703)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:670)
org.apache.jsp.checkBookAcc_jsp._jspService(org.apache.jsp.checkBookAcc_jsp:106)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.sql.SQLException: General error
sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
sun.jdbc.odbc.JdbcOdbc.SQLBindInParameterBigint(Unknown Source)
sun.jdbc.odbc.JdbcOdbcPreparedStatement.setLong(Unknown Source)
org.apache.jsp.chkIsbn_jsp._jspService(org.apache.jsp.chkIsbn_jsp:106)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:703)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:670)
org.apache.jsp.checkBookAcc_jsp._jspService(org.apache.jsp.checkBookAcc_jsp:106)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802) -
How to insert into database using jsp
sir
the code below is to enter the items in the database but it is giving the error .......of null.................
<!-- JAI SHRI RAM -->
<%@ page import="java.sql.*" %>
<html>
<head><title>JAI SHRI RAM</title></head>
<body>
<%
String url = "jdbc:odbc:lala" ;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection(url,"","");
Statement st = conn.createStatement();
for(int i=1 ; i<=13 ; i++)
String skill_type = request.getParameter("skill_type"+i);
String skill_name = request.getParameter("skill_name"+i);
String version = request.getParameter("version"+i);
String lastused = request.getParameter("last_used"+i);
int last_used = Integer.parseInt(lastused);
String proficiency_level = request.getParameter("proficiency_level"+i);
String expinyears = request.getParameter("exp_in_years"+i);
int exp_in_years = Integer.parseInt(expinyears);
String expinmonths = request.getParameter("exp_in_months"+i);
int exp_in_months = Integer.parseInt(expinmonths);
String query = "insert into skills values(1 , '" + skill_type + "' , '" + skill_name + "', '" + version + "', 1 , '" + proficiency_level + "', 1 ,1)";
st.executeUpdate(query);
out.println("JAI SHRI RAM ,,,,,,,, transcation is over");
%>
</body>
</html>
i m using MS ACCESS
please tell me the problem
thank you
gauravHi,
Most probably you have problem in proper initialization of the database driver or the connection url.
In lines shown bellow
String url = "jdbc:odbc:lala" ;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection(url,"","");Try to do that with more simple operations e.g. insert in a table with one field. -
Nicer method for inserting dynamic into a JSP
I have a site layout which has header.jsp, menu.jsp, content.jsp(s), footer.jsp.
Instead of having 10 various topic pages all of which including header,menu, and footer into them, I have opted for one JSP that loads the content.jsp based on a parameter in the URL e.g,
index.jsp?content=news
index.jsp?content=polls
index.jsp?content=products
So far I can do this by :
<jsp:include page="includes/header.jsp" />
<jsp:include page="includes/menu.jsp" />
<%
String content = request.getParameter("content");
String action = request.getParameter("action");
String id = request.getParameter("id");
if(content.equals("news"))
if(action == null)
%>
<jsp:include page="news/content.jsp" />
<%
else if(action != null)
%>
<jsp:include page="news/form.jsp" />
<%
if(content.equals("forums"))
if(action == null)
%>
<jsp:include page="forums/content.jsp" />
<%
else if(action.equals("edit"))
%>
<jsp:include page="forums/showtopic.jsp" />
<%
// other IF blocks here
%>
<%@ include file="includes/footer.jsp" %>
footer.jsp in constant so it is '<%@ include', the header and menu have content which can vary between views so they have '<jsp:include'.
Originally I thought I could have one single
<jsp:include page="<%=content%>/content.jsp" />
or find any means to use the content variable to feed it into the JSP:INCLUDE, but it doesn't seem to be possible.
Does anyone have any ideas for me?
Many thanksOriginally I thought I could have one single
<jsp:include page="<%=content%>/content.jsp" />
or find any means to use the content variable to fee
it into the JSP:INCLUDE, but it doesn't seem to be
possible.
Does anyone have any ideas for me?
Try:
<% String pageName = content + "/content.jsp"; %>
<jsp:include page="<%=pageName%>"/>or
<jsp:include page='<%=content + "/content.jsp"%>' /> -
How can i insert an anchor in edge reflow ?
Hello,
All in my subject :-)
Then, if i can create an anchor, will it be visible in the link window (near the status) ?
Ty for your answerAt this time Reflow does not have anchors. But your assumtion is correct, when we do get them we'd definitely allow them in the link window. For now we just allow page links and outside links.
-
How do you insert name anchors in dreamweaver cc and provide a link in same document?
Pls help me how to solve this problem.
Named anchors are deprecated in HTML so you won't find this option in DW CC. Use a unique id instead.
<h1 id="first">First Anchor</h1>
<a href="#first">Link to First Anchor</a>
Nancy O. -
The codes below allow me to insert a row of record into the database. How would I changed these to insert multiple rows at once? Please help!
String sql = "INSERT INTO EMPLOYEES" +
"(First_Name, Last_Name, Title, Phone) " +
" VALUES " +
PreparedStatement statement = conn.prepareStatement(sql);
statement.setObject (1, First_Name);
statement.setObject (2, Last_Name);
statement.setObject (3, Title);
statement.setObject (4, Phone);
boolean returnValue = statement.execute();You can either create a loop and repeat the insert statement,
or use the addBatch() and executeBatch() methods in the
java.sql.Statement class. -
Need to read data from a jsp and insert in other jsp
Hi,
I have a jsp where i need to read from another jsp(which has data " header ---insert -----footer") and find a string "insert" in it and replace that string with a some value in the current jsp.
Thanx in Advance.
Sridhar.I have a jsp
which needs to take headers and footers dynamically and insert them into my jsp.
currently what i am doing is, using a script to get these header and footer and using document.write
MYJSP.jsp looks this way
<script src="/../Headerfooter.jsp"/>
<script language="javascript">
document.write(header); -->defined in -> /HeaderFooter.jsp
document.write("<table>...</table>");
document.write(footer);-->defined in -> /HeaderFooter.jsp
</script>
/HeaderFooter.jsp looks this way
header = "<html>...<table width=\"100\">....";
footer ="....</html">
i dont want to use script bcoz i am getting problems in nestcape... -
Irregularity with anchor behaviour - inserting anchors in anchored frames
I am experiencing irregular behaviours with anchors and I'm not sure if it's a glitch or something I am overlooking. Sometimes it works, sometimes it dosen't, and I can't tell what is causing the difference.
What I want is an anchored text fram to a main body text - which is an imag caption - and from this text frame I create a new anchored image frame, in which I put the image I am referring to in the caption. Sometimes this process works smoothly, while other times, when I go to insert the anchor in the anchored text frame it re-routes me back to the main body text from where I came. I have tried different insertion points within the anchored text frame, but nothing seems to solve the problem in this scenario....
any ideas?
thanks!Kat,
I hope I understand your problem correctly.
The paragraph containing the figure title is positioned in the side head with alignment set to Top Edge. Then that paragraph is followed by another paragraph, which of course is in the main text column, empty, and aligned at the top with the side head.
With the insertion point in the second paragraph, import the image file. This puts the image below the line. Select the image, not the anchored frame, and scale it if necessary. If not created at the correct size, you probably want to scale it down to fit the width of the text column. Now press the key sequence Esc, m, p (note m and p are lowercase). The anchored frame shrinks to fit tightly around the image and changes it position to At Insertion Point. If you turn on Text Symbols, you will see the end-of-paragraph symbol at the lower right edge of the image, and the top of the anchored frame will align with the TOP of the side head text.
You also have to be sure the line spacing of the paragraph holding the image is NOT fixed or Frame will move the image up.
Hope this is what you need,
Van -
Inserting data from jsp form to multiple tables !
Hi,
I want to insert data from jsp form to two tables
tables are
(1) Form
formId (PK)
deptName
(2) Data
formId (FK)
sNo
description
itemCode
and the problem is that i want to save information form a jsp form to above two tables and i have only one form.
so how do i insert data from a jsp form to multiple tables.You already know what your form in the jsp will be and what fields they are. You also already know what your database looks like. Using one form, you should be able to break the data down, and give it certain ids and/or names, so that when the form is submitted, you retrieve the correct values corresponding to a specific field and insert it.
Unless there is something else I am not catching, this seems pretty straight forward.
Maybe you are looking for
-
Hi people , hope anyone can help with this. How can i change de Language Key at the comunications TAB on the PO Header ? it`s grey from the start and i´m not being able to change it , even before i enter the Vendor. I´ve checked the IMG config menus
-
IWeb doesn't see I'm already logged into MobileMe
When I attempt to publish to my trial account of MobileMe I am getting a pop-up telling me I need a MobileMe account and offers sign up for one or asks me to login to my current account. I click login to my account and it opens MobileMe in system pre
-
So far I really like Arch... but any help with this problem would be great. I have moved from Gentoo to Arch and so far really like it. I am using LVM on LUKS encrypted partition, with KDE base for a desktop manager. This all works perfectly and I a
-
What is the T Code to access this screen
What is the T Code to access this screen with heading <b>Create Transfer Order: Generate Transfer Order Item</b>
-
I'm not able to activate neither imessage nor FaceTime. Its shows -waiting for activation for long time ,but it wont at last. PS:Using Iphone 5s. Please help in this issue. Thanks in advance.