---
title: "Gnäller på variabel request"
type: "forum-thread"
url: "https://www.webforum.nu/amne/java/172152-gnäller-på-variabel-request"
topic: "Java"
topic_url: "https://www.webforum.nu/amne/java"
author: "jwradhe"
published: "2008-06-12T13:28:31.000Z"
updated: "2008-06-12T14:44:37.000Z"
replies: 6
views: 433
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/java/172152-gnäller-på-variabel-request"
---

# Gnäller på variabel request

## #1 — jwradhe, 2008-06-12T13:28Z

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?

Permalänk: https://www.webforum.nu/p/172152

## #2 — Fredde Mannen, 2008-06-12T13:30Z

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

Permalänk: https://www.webforum.nu/p/2117860

## #3 — jwradhe, 2008-06-12T13:40Z

Se bild.<http://www.webforum.nu/attachment.php?attachmentid=&stc=1>

Bilagor:

- [error.jpg](https://www.webforum.nu/a/18349.jpg)

Permalänk: https://www.webforum.nu/p/2117863

## #4 — Peter S, 2008-06-12T13:49Z

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

Permalänk: https://www.webforum.nu/p/2117866

## #5 — jwradhe, 2008-06-12T13:56Z

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?

Permalänk: https://www.webforum.nu/p/2117871

## #6 — Lime, 2008-06-12T14:16Z

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.

Permalänk: https://www.webforum.nu/p/2117874

## #7 — jwradhe, 2008-06-12T14:44Z

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

Permalänk: https://www.webforum.nu/p/2117880

---

Tråden på webben: https://www.webforum.nu/amne/java/172152-gnäller-på-variabel-request
