webForumDet fria alternativet

Gnäller på variabel request

6 svar · 420 visningar · startad av jwradhe

jwradheMedlem sedan juni 2002711 inlägg
#1

Hoho!
Har en javakod där jag försöker köra request.getParameter("NotToBeInovice");
men sen när jag försöker kompilera detta så gnäller den på variabel request.

protected String insertActionInDb(String prId, String userId, String[] to, String[] cc, String solution, String mail,String[] attachmentName, String actionType, String workHours, String workType) throws Exception {
	String sql = "select PersonId from CMCompanyPeople where WUIUserID='"+userId+"'";
	String[][] tab = rh.executeQuery(sql);
	String retInfo = null;
	
	String insertUser = "0";

	try {
		Double.parseDouble(workHours);
	} catch(Exception e) {
		workHours = "0";	
	}

	if (tab.length>0) {
		insertUser = tab[0][0];
	}

	StringBuffer toInsert = new StringBuffer("Email sent to:\n");

	if(to != null) {
		for (int i=0; i<to.length;i++) {
			toInsert.append(to[i]);
			toInsert.append("\n");
		}
	}
	if(cc != null && cc.length>0) {
		toInsert.append("CC:\n");
		for (int i=0; i<cc.length;i++) {
			toInsert.append(cc[i]);
			toInsert.append("\n");
		}
	}
	if(attachmentName != null && attachmentName.length>0) {
		
		for (int i=0;i<attachmentName.length;i++) {
			
			if (attachmentName[i]!= null &&attachmentName[i].length()>0) {
				toInsert.append("Attached file: ");
				toInsert.append(attachmentName[i]);
				toInsert.append("\n");
			}
		}
	}
	
		
	if (mail != null && mail.length() >0) {
		toInsert.append(mail);	
		toInsert.append("\n");
	}
	//toInsert.append("Solution/Status:\n");
	toInsert.append(solution);
		
	String insertString = toInsert.toString();
	if (insertString.length() > 2000) {
		retInfo = "The action text will be truncated<br>due to the long email text.";
		insertString = insertString.substring(0,2000);
	}
	insertString = Util.escapeSingleQuotes(insertString);//Util.decode(insertString, 2));

	[B]String NotToBeInvoice = request.getParameter("NotToBeInovice");[/B]

	sql = "INSERT INTO [PRAction]( [PrId],[PersonId], [CustContactId],[ActionTypeId]"
	+",[CreationDate], [Description], [WorkHours], [WorkTypeId], [NotToBeInvoiced])"
	+" VALUES('" + prId + "','" +insertUser +"','0', '"+actionType+"', getDate(), '"+ insertString+"','"+workHours+"', '"+workType+"', '"+NotToBeInvoice+"')";
	Logging.logDebug(sql);
	rh.executeUpdate(sql);
	rh.executeUpdate("exec spInsertSOAPHeader 0," + prId + " ,0,1");

	
	return retInfo;
}

	protected InternetAddress[] parseEmailAddresses(String toParse) throws Exception{
		
		StringTokenizer strtoken = new StringTokenizer(toParse, ",");
		int iSize = strtoken.countTokens();
		InternetAddress[] retList = new InternetAddress[iSize];

		for(int i = 0; i < iSize; i++) {
			String tmpStr = strtoken.nextToken();
			tmpStr = tmpStr.trim();
			int pos = tmpStr.lastIndexOf(" ");
			String tmpName = "";
			String tmpAddress = "";

			if(pos == -1) { //Just an address if there exist an "@", otherwise just a name
				int atPos = tmpStr.indexOf("@");
				if(atPos == -1) { //Just a Name
					tmpName = tmpStr;
				} else { //Just an address
					tmpAddress = tmpStr;
				}
			} else {
				if( tmpStr.indexOf("@") == -1 ) { //A name with space
					tmpName = tmpStr;
				} else {
					//There is both a name and an address.
					tmpAddress = tmpStr.substring(pos, tmpStr.length());
					tmpName = tmpStr.substring(0, pos);
				}
			}

			//At last remove potential "< >" from the address
			tmpName = tmpName.trim();
			tmpAddress = tmpAddress.trim();
			if(tmpAddress.indexOf("<") == 0) {
				tmpAddress = tmpAddress.substring(1, (tmpAddress.length()-1));
			}
			retList[i] = new InternetAddress(tmpAddress, tmpName);
		}
		return retList;
	}

Nån aning om varför detta?

Fredde MannenMedlem sedan nov. 20014 054 inlägg
#2

Vad ger den för fel, när den gnäller?

jwradheMedlem sedan juni 2002711 inlägg
Peter SMedlem sedan dec. 20025 483 inlägg
#4

Har du importerat det paket som request finns i? Eller är det så att request kanske skall skickas med som parameter?

jwradheMedlem sedan juni 2002711 inlägg
#5

Jag har väldigt låg kunskap om java, så jag vet inte :) Inte jag som skrivit koden, utan ja ska endast lägga till ett värde i INSERT sql satsen.

Vart ser jag om det är importerat?

LimeMedlem sedan sep. 2001961 inlägg
#6

Som jag ser det så finns inte request deklarerat någonstans i metoden insertActionInDb. Antingen måste du skicka med request-instansen till metoden eller så måste du göra den nåbar som ett attribut.

jwradheMedlem sedan juni 2002711 inlägg
#7

ahh ok :) ska försöka förstå vad det innebär :)

131 ms totalt · 3 externa anrop · v20260731065814-full.a4c710cd
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
128 ms — hämta tråd, inlägg och bilagor (db)